Skip to main content

Command Palette

Search for a command to run...

Different Syntax Of Writing map() in javascript

Updated
1 min readView as Markdown
Different Syntax Of Writing map() in javascript

1st:

const array1 = rockets.map(elem => (
  {
    country: elem.country,
    launches: elem.launches
  }
));

 console.log(array1);       [{… }, {… }, {… }]

2s

const array2 = rockets.map(elem => {
  return {
    country: elem.country,
    launches: elem.launches 
  }
});


 console.log(array1);       [{… }, {… }, {… }]

More from this blog

Omar's blog

135 posts