js remove several elements from array

Solutions on MaxInterview for js remove several elements from array by the best coders in the world

showing results for - "js remove several elements from array"
Tim
23 Jan 2020
1var ar = ['zero', 'one', 'two', 'three'];ar.shift(); // returns "zero"console.log( ar ); // ["one", "two", "three"]
Louis
17 Feb 2020
1var array = [1, 2, 3, 4];var evens = _.remove(array, function(n) { return n % 2 === 0;});console.log(array);// => [1, 3]console.log(evens);// => [2, 4]
Abigail
24 May 2018
1var ar = [1, 2, 3, 4, 5, 6];ar.length = 4; // set length to remove elementsconsole.log( ar ); // [1, 2, 3, 4]
María Paula
17 Aug 2016
1var ar = [1, 2, 3, 4, 5, 6];ar.pop(); // returns 6console.log( ar ); // [1, 2, 3, 4, 5]
Théo
08 Sep 2018
1var arr1 = [1, 2, 3, 4, 5, 6];var arr2 = arr1; // Reference arr1 by another variable arr1 = [];console.log(arr2); // Output [1, 2, 3, 4, 5, 6]