zig.com Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Arrays</h1>
<h2>The map() Method</h2>
<p>Create a new array by performing a function on each array element:</p>
<p id="demo"></p>
<script>
  const numbers1 = [45, 4, 9, 16, 25];
  const numbers2 = numbers1.map(myFunction);
  document.getElementById("demo").innerHTML = numbers2;
  function myFunction(value, index, array) {
    return value * 2;
  }
</script>
</body>
<!-- /js/tryit.asp?filename=tryjs_array_map  Thu, 06 Feb 2025 18:15:26 GMT -->
</html>