What is object.key()??
I am unable to understand this pls help
5 Replies
Object.keys()
gives you an array of all the keys in a given object:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keysMDN Web Docs
Object.keys() - JavaScript | MDN
The Object.keys() static method returns an array of a given object's own enumerable string-keyed property names.
thank you
it actually only gives an array of enumerable keys, which means, stuff like
toString()
and others wont be in the arrayIt won't include keys from prototypes, any key set to not be enumerable, and keys that are symbols.
thats what i said: only enumerable keys