Is the IN operator a linear search operation, like the indexOf() array method?
I want to check the presence of a property in an object for each element in an array, using if (key in obj)
, in order to avoid nesting iterative operations.
I've checked the spec and there is very little information about the IN operator.
Does it iterate over an object's keys, resulting in a linear time operation? Or does it simply attempt a direct lookup of the key, resulting in a constant time operation?