Object.keys, values, entries Flashcards

1
Q

– returns an array of keys in an object

A

Object.keys(obj)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

– returns an array of values in an object

A

Object.values(obj)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

returns an array of [key, value] pairs in an object

A

Object.entries(obj) –

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Just like a for..in loop, these methods ignore properties that use __________as keys

A

Symbol(…)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The _______________ static method transforms a list of key-value pairs into an object.

A

Object.fromEntries()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

const entries = new Map([
[‘foo’, ‘bar’],
[‘baz’, 42]
]);

const obj = Object.fromEntries(entries);

console.log(obj);
// returns?

A

Expected output:

Object { foo: “bar”, baz: 42 }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

const entries = new Map([
[‘foo’, ‘bar’],
[‘baz’, 42]
]);

const obj = /* write code here */

console.log(obj);
// Expected output: Object { foo: “bar”, baz: 42 }

A

Object.fromEntries(entries);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly