At position 2, remove 2 items: - Javascript Array

Javascript examples for Array:splice

Description

At position 2, remove 2 items:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
var fruits = ["a","b","c","d","e", "Kiwi"];
document.getElementById("demo").innerHTML = fruits;

function myFunction() {//from  w ww .  j ava  2 s  . c o  m
    fruits.splice(2, 2);
    document.getElementById("demo").innerHTML = fruits;
}
</script>

</body>
</html>

Related Tutorials