keys

最后更新于:2022-04-02 00:05:19

## keys + [link](./keys "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L11332 "View in source.") + [npm](https://www.npmjs.com/package/lodash.keys "See the npm package.") ``` _.keys(object) ``` 创建 `object` 自身可枚举属性名为一个数组。 **注意:** 非对象的值会被强制转换为对象,查看 [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) 了解详情 ### 参数 1. object (Object) 要检索的对象 ### 返回值 (Array) 返回包含属性名的数组 ### 示例 ``` function Foo() { this.a = 1; this.b = 2; } Foo.prototype.c = 3; _.keys(new Foo); // => ['a', 'b'] (无法保证遍历的顺序) _.keys('hi'); // => ['0', '1'] ```
';