News for hackers. Stuff that matters.
Re:ES6 in Depth – Symbols by teechap on Friday June 12, 2015 @08:44AM (#9705474)
Linear definitely isn't faster than binary search. To answer your original question, .indexOf is definitely implemented as linear search in JavaScript
Re:ES6 in Depth – Symbols by Demiurge on Friday June 12, 2015 @08:50AM (#9705505)
Ok, it makes sense to me now. indexOf is used on mostly unsorted things, like strings. So, I guess the original problem might use a sorted array, or an object instead of an array, since I think the object keys are sorted and looked up pretty fast.