Object.keys, values, entries Flashcards
– returns an array of keys in an object
Object.keys(obj)
– returns an array of values in an object
Object.values(obj)
returns an array of [key, value] pairs in an object
Object.entries(obj) –
Just like a for..in loop, these methods ignore properties that use __________as keys
Symbol(…)
The _______________ static method transforms a list of key-value pairs into an object.
Object.fromEntries()
const entries = new Map([
[‘foo’, ‘bar’],
[‘baz’, 42]
]);
const obj = Object.fromEntries(entries);
console.log(obj);
// returns?
Expected output:
Object { foo: “bar”, baz: 42 }
const entries = new Map([
[‘foo’, ‘bar’],
[‘baz’, 42]
]);
const obj = /* write code here */
console.log(obj);
// Expected output: Object { foo: “bar”, baz: 42 }
Object.fromEntries(entries);