Skip to content

Function: isObject() ​

ts
function isObject(value): value is Record<string, unknown>;

Checks if a value is an object (including arrays, but excluding null). 检查值是否为对象(包括数组,但排除null)。

Parameters ​

ParameterTypeDescription
valueunknownThe value to check / 要检查的值

Returns ​

value is Record<string, unknown>

True if the value is an object / 如果值是对象则返回true

Example ​

typescript
isObject({}) // => true
isObject({ name: 'John' }) // => true
isObject([1, 2, 3]) // => true
isObject(new Date()) // => true
isObject(/regex/) // => true
isObject(() => {}) // => true
isObject(null) // => false
isObject(undefined) // => false
isObject('string') // => false
isObject(123) // => false

Since ​

1.0.0

Released under the MIT License.