Checks if `n` is between `start` and up to, but not including, `end`. If `end` is not specified, it's set to `start` with `start` then set to `0`. If `start` is greater than `end` the params are swapped to support negative ranges.
inRange(3, 2, 4)
// => true
inRange(4, 8)
// => true
inRange(4, 2)
// => false
inRange(2, 2)
// => false
inRange(1.2, 2)
// => true
inRange(5.2, 4)
// => false
inRange(-3, -2, -6)
// => true
Name | Type | Attribute | Description |
---|---|---|---|
number | The number to check. | ||
start | The start of the range. | ||
end | The end of the range. |
{ "comment": "/**\r\n * Checks if `n` is between `start` and up to, but not including, `end`. If\r\n * `end` is not specified, it's set to `start` with `start` then set to `0`.\r\n * If `start` is greater than `end` the params are swapped to support\r\n * negative ranges.\r\n *\r\n * @since 3.3.0\r\n * @category Number\r\n * @param {number} number The number to check.\r\n * @param {number} [start=0] The start of the range.\r\n * @param {number} end The end of the range.\r\n * @returns {boolean} Returns `true` if `number` is in the range, else `false`.\r\n * @see range, rangeRight\r\n * @example\r\n *\r\n * inRange(3, 2, 4)\r\n * // => true\r\n *\r\n * inRange(4, 8)\r\n * // => true\r\n *\r\n * inRange(4, 2)\r\n * // => false\r\n *\r\n * inRange(2, 2)\r\n * // => false\r\n *\r\n * inRange(1.2, 2)\r\n * // => true\r\n *\r\n * inRange(5.2, 4)\r\n * // => false\r\n *\r\n * inRange(-3, -2, -6)\r\n * // => true\r\n */", "meta": { "range": [ 899, 1050 ], "filename": "inRange.js", "lineno": 39, "path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo", "code": { "id": "astnode100003704", "name": "inRange", "type": "FunctionDeclaration", "paramnames": [ "number", "start", "end" ] }, "vars": { "end": "inRange~end", "start": "inRange~start" } }, "description": "Checks if `n` is between `start` and up to, but not including, `end`. If\r`end` is not specified, it's set to `start` with `start` then set to `0`.\rIf `start` is greater than `end` the params are swapped to support\rnegative ranges.", "since": "3.3.0", "tags": [ { "originalTitle": "category", "title": "category", "text": "Number", "value": "Number" } ], "params": [ { "type": { "names": [ "number" ] }, "description": "The number to check.", "name": "number" }, { "type": { "names": [ "number" ] }, "optional": true, "defaultvalue": 0, "description": "The start of the range.", "name": "start" }, { "type": { "names": [ "number" ] }, "description": "The end of the range.", "name": "end" } ], "returns": [ { "type": { "names": [ "boolean" ] }, "description": "Returns `true` if `number` is in the range, else `false`." } ], "see": [ "range, rangeRight" ], "examples": [ "inRange(3, 2, 4)\r// => true\r\rinRange(4, 8)\r// => true\r\rinRange(4, 2)\r// => false\r\rinRange(2, 2)\r// => false\r\rinRange(1.2, 2)\r// => true\r\rinRange(5.2, 4)\r// => false\r\rinRange(-3, -2, -6)\r// => true" ], "name": "inRange", "longname": "inRange", "kind": "function", "scope": "global", "___id": "T000002R000381", "___s": true, "filepath": "inRange.js" }