JavaScript TypedArray map() Method

The JavaScript map() method form a new array creates a new typed array with the results of calling a provided function on every element in this typed array.

NOTE: map() method does not change the actual array.

Syntax:

Parameters:

Value(Required): The value of the current element.

Index(Optional): The array index of the current element.

arr(Optional): The array map() was called upon.

ThisValue(Optional): A value to be passed to the function to be used as its "this" value.

Return value:

A new array.

Browser Support:

ChromeYes
SafariYes
Firefox1.5
OperaYes

Example 1

JavaScript map() Method

Test it Now

Output:

2,4,6

Example 2

JavaScript map() Method

Test it Now

Output:

10,1,3,5





Latest Courses