The most basic of search algorithms. This algorithm steps sequentially through an array, checking each element for equality with the element to be found. It returns the index of the found element if it is found, or -1 if it doesn’t exist in the array.

Interestingly a simple implementation of linear search can be faster than the builtin function indexOf(). This is caused by Javascript compiling to fast native code, and the builtin function doing more work, such as handling edge cases, see https://github.com/codemix/fast.js.