javascript - use property value as property key using map -


this question has answer here:

i want return new array take property value become property name.

const temp = [   {name: 'james'},   {name: 'ally'} ]  const new = temp.map(obj => ({     `${obj.name}`: null })) 

obviously doesn't work way. clue? https://jsfiddle.net/qg8ofom1/

const temp = [    {name: 'james'},    {name: 'ally'}  ];    const newobj = temp.map(obj => ({      [obj.name]: null  }));    console.log(newobj);


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -