Keys, Values, Entries ( ) Methods
Video
JavaScript Notes
JavaScript
/****************************************************
Object.keys(obj)
Object.values(obj) Object.entries(obj)
Create an iterable object from the Object
*****************************************************/
let westeros = {
cersei: 'Lannister',
arya: 'Stark',
jon: 'Snow',
brienne: 'Tarth',
daenerys: 'Targaryen',
theon: 'Greyjoy',
jorah: 'Mormont',
margaery: 'Tyrell',
sandor: 'Clegane',
samwell: 'Tarly',
ramsay: 'Bolton'
}
let keys = Object.keys(westeros); // returns an array of the keys in the object
let vals = Object.values(westeros); // returns an array of the values in the object
let entries = Object.entries(westeros); // returns an array of both the keys and values in the object
Feedback
Submit and view feedback