Does indexOf simply walk through the array or does it do something that is faster? I know that this is implementation dependent but what does Chrome or Firefox do?
In ECMA6, you have the Set(), and then you can do:
Set()
var obj = new Set(); obj.add(1); obj.has(1) === true; obj.has(2) === false;
The performance of has is O(1).
has