Skip to content

Function: inRange() ​

ts
function inRange(
   value, 
   start, 
   end): boolean;

Whether value lies in the closed interval between start and end (bounds may be reversed). 判断 value 是否在 start 与 end 构成的闭区间内(起止可颠倒)。

Parameters ​

ParameterTypeDescription
valuenumberValue to test / 待判断的值
startnumberInterval bound / 区间一端
endnumberInterval bound / 区间另一端

Returns ​

boolean

True if inside inclusive range / 在区间内为 true

Example ​

ts
inRange(5, 1, 10) // => true

Since ​

1.0.0

Released under the MIT License.