Function: has()
ts
function has(object, path): boolean;Checks whether an object has a property at the given path. 判断对象在指定路径上是否存在属性。
Parameters
| Parameter | Type | Description |
|---|---|---|
object | unknown | Source object / 源对象 |
path | string | readonly PropertyKey[] | Property path / 属性路径 |
Returns
boolean
True when the path exists / 路径存在则为 true
Example
ts
has({ a: { b: 1 } }, 'a.b')
// => trueSince
1.2.0