JavaScript Array forEach() Method

In this tutorial learn how works Array with foreach() loop in javaScript, List each item in the array example:




 <!DOCTYPE html>
<html>
<body>

<p>List all array items, with keys and values:</p>

<p id="result"></p>

<script>
var fruits = ["Mango", "Banana", "Pineaple"];

fruits.forEach(foreachdemo);

function foreachdemo(item, index) {
  document.getElementById("result").innerHTML += index + ":" + item + "<br>"; 
}
</script>

</body>
</html>

No comments:

Post a Comment

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...