Currently this is my code for getting the key that I want from my Object:
for (let [key, value] of Object.entries(d)) {
if (key == input){
//do something
}
}
Is there a faster way to get that key without iterating through every entry? Thank you
CodePudding user response:
You're probably looking for:
d[input]
CodePudding user response:
Find will find and return first element founded, so theoretically if you element lays first it will be blazing fast
Object.keys(obj).find(key => obj[key] === value)