javascript - Convert array of string to array of object using es6 or lodash -


i have array of string want turn array of object.

array = ['a', 'b', 'c']; 

i want generate

array= [   {'name': 'a', 'ischecked': false, 'availibility': 0 },   {'name': 'b', 'ischecked': false, 'availibility': 0 },   {'name': 'b', 'ischecked': false, 'availibility': 0 } ]; 

i tried below , still returning originalarray!

array.map((name) => ({   name,   ischecked: false,   availability: 0 })); 

how this?

you can use map this:

array= ['a', 'b', 'c'];  let newarr = array.map(item => {    return {      'name': item,      'ischecked': false,      'availibility': 0    }  })    console.log(newarr);


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -