1var colors=["red","green","blue","yellow"];
2//loop back-words through array when removing items like so:
3for (var i = colors.length - 1; i >= 0; i--) {
4 if (colors[i] === "green" || colors[i] === "blue") {
5 colors.splice(i, 1);
6 }
7}
8//colors is now  ["red", "yellow"]
1const nums = [1, 2, 3, 4, 5, 6];
2const remove = [1, 2, 4, 6];
3
4function removeFromArray(original, remove) {
5 return original.filter(value => !remove.includes(value));
6}
1var ar = ['zero', 'one', 'two', 'three'];ar.shift(); // returns "zero"console.log( ar ); // ["one", "two", "three"]
1const colors=["red","green","blue","yellow"];
2let index = colors.length - 1;
3while (index >= 0) {
4 if (['green', 'blue'].indexOf(colors[index]) > (-1)) {
5 colors.splice(index, 1);
6 }
7 index -= 1;
8}
1var ar = [1, 2, 3, 4, 5, 6];ar.pop(); // returns 6console.log( ar ); // [1, 2, 3, 4, 5]
1var ar = [1, 2, 3, 4, 5, 6];ar.length = 4; // set length to remove elementsconsole.log( ar ); // [1, 2, 3, 4]