Answers for "convery array of objects to map using immutables js"

0

convery array of objects to map using immutables js

const sample = [{"id":"10","name":"Dave","urlName":"foo-bar","order":"-100","classId":"12","className":"David","classUrlName":"david-foo-bar"}];

const result = sample.reduce((acc, item) => {
  return acc.set(item.name, {
     id: item.id,
     urlName: item.urlName,
   })
}, new Immutable.Map())

console.log("Dave's Id", result.getIn(["Dave", "id"]));
console.log("Date's urlName", result.getIn(["Dave", "urlName"]));
Posted by: Guest on April-19-2021

Code answers related to "convery array of objects to map using immutables js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language