has
最后更新于:2022-04-02 00:05:07
## has
+ [link](./has "Link to this entry.")
+ [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L11200 "View in source.")
+ [npm](https://www.npmjs.com/package/lodash.has "See the npm package.")
```
_.has(object, path)
```
检查 `path` 是否是对象的直接属性。
### 参数
1. object (Object)
要检索的对象
2. path (Array|string)
要检查的路径
### 返回值 (boolean)
如果存在返回 true,否则返回 `false`
### 示例
```
var object = { 'a': { 'b': { 'c': 3 } } };
var other = _.create({ 'a': _.create({ 'b': _.create({ 'c': 3 }) }) });
_.has(object, 'a');
// => true
_.has(object, 'a.b.c');
// => true
_.has(object, ['a', 'b', 'c']);
// => true
_.has(other, 'a');
// => false
```
';