Quick tip! Map loop, already returns a array

baltz - Aug 9 '19 - - Dev Community

It is common to see this approach when we are creating a new array using map loop

const newArray = []

array.map((item) => {
  newArray.push(item.value)
})
Enter fullscreen mode Exit fullscreen mode

Right? but map loop already returns a array.
So we can do that instead

const newArray = array.map((item) => {
  return item.value
})

Enter fullscreen mode Exit fullscreen mode

Cool huh!
Cool huh!

. . . . . . . .
Terabox Video Player