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 -

Python Tornado package error when running server -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -