Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

indexOf

oatkiller edited this page Sep 13, 2010 · 4 revisions

taken from mozillas wobsite. this lives on array prototype and has a bad naming scheme in honor of mozilla. use it to brute force calculate the index of an element in an array.

(function () {
	
['a','b','c'][o.indexOf]('b'); // returns 1
	
})();

details

this uses the same api and algorithm as mozillas native implementation. if the client is mozilla or has a native implementation, oatlib will use that instead, since c is faster to execute than javascript at this time :( :( :(

more

mozillas page about indexOf

Clone this wiki locally