Object.keys equivalent lodash method

放肆的年华 提交于 2019-12-03 23:49:36

_.keys should do the trick.

_.keys(object)

Creates an array of the own enumerable property names of object.

Example:

console.log(_.keys({ "tab1": "1" , tab2: "2"}));
console.log(Object.keys({ "tab1": "1" , tab2: "2"}));

// Outputs:
// ["tab1", "tab2"]
// ["tab1", "tab2"]
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.5.1/lodash.js"></script>

Side-note:

Remember that the keys of an object are not necessarily ordered, and so they can come back in any order the host chooses.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!