I am new to loadash, I am trying to learn good ways to manipulate java script object.
Is there a equivalent loadash method for :
Object.keys({ "tab1": "1" , tab2: "2"})[0];
Object.keys({ "tab1": "1" , tab2: "2"})[2];
to get list values?
And also if there are easy and good ways to use lodash and any articles that I can go through.
_.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.
来源:https://stackoverflow.com/questions/35566472/object-keys-equivalent-lodash-method