Skip to content

Latest commit

 

History

History
16 lines (9 loc) · 416 Bytes

map-method.md

File metadata and controls

16 lines (9 loc) · 416 Bytes

How to Use the Map Method


In JavaScript, the .map() method allows you to create a new array by returning the results of calling a function that you provide on every element in a given array.

const numbers = [1, 2, 3, 4, 5]

const squared = numbers.map((num) => num * num)

console.log(squared)

link