Today I discovered something you should know about
splice() has a first parameter of
index which is supposed to be a number representing the index of the array you wish to splice at. Well, apparently when this
index is undefined it acts as though you passed
// Create a sample array var array = [ 'a', 'b', 'c' ]; console.log(array); // Remove 1 element from index undefined array.splice(undefined, 1); console.log(array); /** * OUTPUT * * [ 'a', 'b', 'c' ] * [ 'b', 'c' ] */
Keep this in mind next time you’re using
Array.splice() as it is very unexpected behaviour.