delete obj from array javascript code example

Example 1: js remove item from array by value

var arr = ['bill', 'is', 'not', 'lame'];

arr.splice(output_items.indexOf('not'), 1);

console.log(arr) //returns ['bill', 'is', 'lame']

Example 2: how to find and remove object from array in javascript

var id = 88;

for(var i = 0; i < data.length; i++) {
    if(data[i].id == id) {
        data.splice(i, 1);
        break;
    }
}

Example 3: javascript delete object from array

someArray.splice(x, 1);

Example 4: how to delete object in array

let array = [1,2,3];
let item = array.indexOf(2)
let deleteCount = 1;
array.splice(item, deleteCount)