JavaScript: map()

ยท

1 min read

Map() is one of the very useful functions. It creates a new array. The function (which will be passing in the map function) is going to apply to every element in the original array.

const fruits = ['apple', 'banana', 'grape'];
fruits.map((item) => {
    console.log(`${item} ๐Ÿ˜‹`);
});

'item' can be replaced with any words

Result

image.png

Reference: MDN