remove the matched element value in the array js code example

Example 1: javascript remove object from array

var array = ['Object1', 'Object2'];

// SIMPLE
	array.pop(object); // REMOVES OBJECT FROM ARRAY (AT THE END)
	// or
	array.shift(object); // REMOVES OBJECT FROM ARRAY (AT THE START)

// ADVANCED
	array.splice(position, 1);
	// REMOVES OBJECT FROM THE ARRAY (AT POSITION)

		// Position values: 0=1st, 1=2nd, etc.
		// The 1 says: "remove 1 object at position"

Example 2: how to delete an element from an array in javascript

var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];var removed = arr.splice(2,2);/*removed === [3, 4]arr === [1, 2, 5, 6, 7, 8, 9, 0]*/