remove a particular element from an array in JavaScript?
var array = [2, 5, 9];
console.log(array)
var index = array.indexOf(5);
if (index > -1) {
array.splice(index, 1);
}
// array = [2, 9]
console.log(array);
remove a property from a JavaScript object? delete myObject.regex; // or, delete myObject['regex']; // or, var prop = ...
No comments:
Post a Comment