TypedArray map() JavaScript

The Javascript TypedArray map() method forms a new array with the result of calling a function for every element.

Syntax:

array.map(function(value, index, arr), thisValue)

Parameters:
value: It represents the current element’s value.
index: It represents the index position of the current element.
arr: It represents the array on which map() is called.
thisValue: It represents this argument for the function.

Returns:
New Array.

Example 1:

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">   
var Jewels = ["DIAMOND","GOLD","PLATINUM","SILVER"];
var gems =Jewels.map(function(Jewels)  
{  return Jewels + " Jewellery ";  });    
document.write(gems);  
</script>
</body>
</html>

Example 2:

<!DOCTYPE html>
<html>
<body>
<script type="text/javascript"> 
const testArray = new Uint8Array([100, 36]);
const roots = testArray.map(Math.sqrt);
 
document.write(roots);
 
</script>
</body>
</html>