Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
131
rated 0 times [  138] [ 7]  / answers: 1 / hits: 42309  / 8 Years ago, tue, february 23, 2016, 12:00:00

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.


More From » lodash

 Answers
18

_.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.


[#63210] Sunday, February 21, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
loric

Total Points: 110
Total Questions: 96
Total Answers: 91

Location: Estonia
Member since Wed, Jun 8, 2022
2 Years ago
;