Checks if a value is of a given type.
检查值是否为给定类型。
The value to check. 要检查的值
The type to check against. 要检查的类型
True if the value is of the given type, false otherwise. 如果值为给定类型则返回 true,否则返回 false
isTypeof(null, 'null') // => trueisTypeof(undefined, 'undefined') // => trueisTypeof({}, 'object') // => trueisTypeof([], 'array') // => trueisTypeof(new Map(), 'map') // => trueisTypeof(() => {}, 'function') // => trueisTypeof(42, 'string') // => false Copy
isTypeof(null, 'null') // => trueisTypeof(undefined, 'undefined') // => trueisTypeof({}, 'object') // => trueisTypeof([], 'array') // => trueisTypeof(new Map(), 'map') // => trueisTypeof(() => {}, 'function') // => trueisTypeof(42, 'string') // => false
Checks if a value is of a given type.
检查值是否为给定类型。