I'm trying to extract some values from an object and put them into an array. So far I have this:
let obj = {
a: 'a',
b: 'b',
c: 'c',
d: 'd',
e: 'e'
};
let arr = [{a, b, c} = obj];
console.log(arr);
However, this is returning an array with just one object:
[ { a: 'a', b: 'b', c: 'c', d: 'd', e: 'e' } ]
My desired output would be:
['a', 'b', 'c']
Does anyone know what I'm doing wrong?
{a, b, c} = objjust takes the first three values of your array and put them into three new variables,a,bandc.['a', 'b', 'c']?