JavaScript has a couple features that I wasn’t aware of until I saw a recent video on Node.js.
- — splice – A function to pull out a single element from an array. So [1,2,3,4,5].splice(1,1); will return 2. Additionally the array will afterwords look like [1,3,4,5].
- — indexOf – Need to find out what a specific index number for a given value is (basically a reverse index look-up) something like [8,7,6,5,4].indexOf(7); will return a 1. I actually thought indexOf was a function of the HTML DOM for some reason.
- — delete – Built in function to delete a specific index of an array. Something like a=[5,6,7,8]; delete a[0] will remove the individual entry for a[0]. Now depending on environment delete will shorten the array for that element, some environments will simply turn that array element to null effectively blanking out that one entry.