Javascript examples for Array:splice
Removing an array element using splice() method
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/* w w w.j a v a2 s . c o m*/ var arr = ["copper", "oil", "silver", "bronze", "gold", "iron"]; for (var i = 0; i < arr.length; i++) { if (arr[i].indexOf('l') !== -1) { arr.splice(i, 1); i = i - 1; } } console.log(arr) } </script> </head> <body> </body> </html>