Javascript examples for Array Operation:Array Element
Click the button to add elements to the array
<html> <head></head> <body> <p>Click the button to add elements to the array.</p> <button onclick="myFunction(3)">Try it</button> <p id="demo"></p> <script> var fruits = ["Banana", "Orange", "Apple", "Mango"] document.getElementById("demo").innerHTML = fruits; function myFunction(index) {//from ww w. j a va2 s. c om console.log(index) fruits.splice(index, 1); document.getElementById("demo").innerHTML = fruits; } </script> </body> </html>