js remove function code example
Example 1: remove a particular element from array
var colors = ["red","blue","car","green"];
var carIndex = colors.indexOf("car");
colors.splice(carIndex, 1);
Example 2: remove javascript
var elem = document.getElementById("myDiv");
elem.parentNode.removeChild(elem);
Example 3: remove in javascript
function arrayRemove(arr, value)
{
return arr.filter(function(ele){
return ele != value;
});
}
Example 4: Js remove
var ar = [1, 2, 3, 4, 5, 6];
ar.pop();
console.log( ar );
ar.shift();
console.log( ar );
for ( var i = 0; i < ar.length; i++){
if (ar[i] === 2 )
ar.splice(i, 1);
}
console.log( ar );