I was curious as of what would be the fastest way to check if a JS object (used as a dictionary) has a given property.
And I was baffled by the results. See for yourself: http://jsperf.com/object-membership-check-speed/6
In Chrome, the in
keyword method is 96% slower than the dot syntax.
And in Firefox, it's also around 80% slower. IE shows about 50% slower
What the hell? Am I doing something wrong? I imagined the "in" keyword would be optimized, since it doesn't even need to get the value, it just returns a boolean. But I guess I was wrong.