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

meteor - inserting data to database gives error "insert failed: Method '/texts/insert' not found" -

angular - DownloadURL return null in below code -