Skip to content

Instantly share code, notes, and snippets.

@prof3ssorSt3v3
Created June 26, 2018 03:57
Show Gist options
  • Save prof3ssorSt3v3/b3779e85e74ecd8b2ba0dec1e7dd6ae6 to your computer and use it in GitHub Desktop.
Save prof3ssorSt3v3/b3779e85e74ecd8b2ba0dec1e7dd6ae6 to your computer and use it in GitHub Desktop.
/**********************************
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'
}
//for(let prop of arr)
// foreach( ) filter( ) map() reduce()
let keys = Object.keys(westeros);
//console.log('Keys ', keys);
let vals = Object.values(westeros);
//console.log('Vals', vals);
let entries = Object.entries(westeros);
console.log('Entries', entries);
console.log( entries[2][1] );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment