方法
# static isArguments(value)
Checks if value is likely an arguments object.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 0.1.0
 
Returns true if value is an arguments object, else false.
示例
isArguments(function() { return arguments }())
// => true
isArguments([1, 2, 3])
// => false# static isArray(value)
Checks if value is Array.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 0.1.0
 
Returns true if value is Array, else false.
示例
isArray([1,2,3])
// => true# static isArrayLike(value)
Checks if value is array-like. A value is considered array-like if it's
not a function and has a value.length that's an integer greater than or
equal to 0 and less than or equal to Number.MAX_SAFE_INTEGER.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 4.0.0
 
Returns true if value is array-like, else false.
示例
isArrayLike([1, 2, 3])
// => true
isArrayLike(document.body.children)
// => true
isArrayLike('abc')
// => true
isArrayLike(Function)
// => false# static isArrayLikeObject(value)
This method is like isArrayLike except that it also checks if value
is an object.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 4.0.0
 
Returns true if value is an array-like object,
else false.
示例
isArrayLikeObject([1, 2, 3])
// => true
isArrayLikeObject(document.body.children)
// => true
isArrayLikeObject('abc')
// => false
isArrayLikeObject(Function)
// => false# static isBoolean(value)
Checks if value is classified as a boolean primitive or object.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
Returns true if value is a boolean, else false.
示例
isBoolean(false)
// => true
isBoolean(null)
// => false# static isElement(value)
Checks if value is likely a DOM element.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 0.1.0
 
Returns true if value is a DOM element, else false.
示例
isElement(document.body)
// => true
isElement('<body>')
// => false# static isError(value)
Checks if value is an Error, EvalError, RangeError, ReferenceError,
SyntaxError, TypeError, or URIError object.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 3.0.0
 
Returns true if value is an error object, else false.
示例
isError(new Error)
// => true
isError(Error)
// => false# static isFunction(value)
Checks if value is classified as a Function object.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 0.1.0
 
Returns true if value is a function, else false.
示例
isFunction(class Any{})
// => true
isFunction(() => {})
// => true
isFunction(async () => {})
// => true
isFunction(function * Any() {})
// => true
isFunction(Math.round)
// => true
isFunction(/abc/)
// => false# static isLength(value)
Checks if value is a valid array-like length.
Note: This method is loosely based on
ToLength.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 4.0.0
 
Returns true if value is a valid length, else false.
示例
isLength(3)
// => true
isLength(Number.MIN_VALUE)
// => false
isLength(Infinity)
// => false
isLength('3')
// => false# static isNative(value)
Checks if value is a pristine native function.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 3.0.0
 
Returns true if value is a native function,
else false.
示例
isNative(Array.prototype.push)
// => true
isNative(isDate)
// => false# static isNil(value)
Checks if value is null or undefined.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 4.0.0
 
Returns true if value is nullish, else false.
示例
isNil(null)
// => true
isNil(void 0)
// => true
isNil(NaN)
// => false# static isNull(value)
Checks if value is null.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 0.1.0
 
Returns true if value is null, else false.
示例
isNull(null)
// => true
isNull(void 0)
// => false# static isNumber(value)
Checks if value is classified as a Number primitive or object.
Note: To exclude Infinity, -Infinity, and NaN, which are
classified as numbers, use the Number.isFinite method.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 0.1.0
 
- See:
- 
        - isInteger, toInteger, toNumber
 
Returns true if value is a number, else false.
示例
isNumber(3)
// => true
isNumber(Number.MIN_VALUE)
// => true
isNumber(Infinity)
// => true
isNumber('3')
// => false# static isObject(value)
Checks if value is the
language type
of Object. (e.g. arrays, functions, objects, regexes, new Number(0), and new String(''))
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 0.1.0
 
Returns true if value is an object, else false.
示例
isObject({})
// => true
isObject([1, 2, 3])
// => true
isObject(Function)
// => true
isObject(null)
// => false# static isObjectLike(value)
Checks if value is object-like. A value is object-like if it's not null
and has a typeof result of "object".
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
Returns true if value is object-like, else false.
示例
isObjectLike({})
// => true
isObjectLike([1, 2, 3])
// => true
isObjectLike(Function)
// => false
isObjectLike(null)
// => false# static isPlainObject(value)
Checks if value is a plain object, that is, an object created by the
Object constructor or one with a [[Prototype]] of null.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 0.8.0
 
Returns true if value is a plain object, else false.
示例
function Foo() {
  this.a = 1
}
isPlainObject(new Foo)
// => false
isPlainObject([1, 2, 3])
// => false
isPlainObject({ 'x': 0, 'y': 0 })
// => true
isPlainObject(Object.create(null))
// => true# static isString(value)
Checks if value is classified as a String primitive or object.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 0.1.0
 
Returns true if value is a string, else false.
示例
isString('abc')
// => true
isString(1)
// => false# static isSymbol(value)
Checks if value is classified as a Symbol primitive or object.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 4.0.0
 
Returns true if value is a symbol, else false.
示例
isSymbol(Symbol.iterator)
// => true
isSymbol('abc')
// => false# static isUndefined(value)
Checks if value is undefined.
参数:
| 名称 | 类型 | 描述 | 
|---|---|---|
| value | * | The value to check. | 
- Since:
- 0.1.0
 
Returns true if value is undefined, else false.
示例
isUndefined(void 0)
// => true
isUndefined(null)
// => false