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.
The _. keys() method is used to return the list of all keys of the given object. Parameters: This method accepts a single parameter as mentioned above and described below: object: This parameter holds the object elements.
In Lodash, we can deeply compare two objects using the _. isEqual() method. This method will compare both values to determine if they are equivalent.
Lodash is a popular javascript based library which provides 200+ functions to facilitate web development. It provides helper functions like map, filter, invoke as well as function binding, javascript templating, deep equality checks, creating indexes and so on.
_.keys
should do the trick.
_.keys(object)
Creates an array of the own enumerable property names of
object
.
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>
Remember that the keys of an object are not necessarily ordered, and so they can come back in any order the host chooses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With