8 comments

[ 2.9 ms ] story [ 27.1 ms ] thread
'===' performs better than '==' because no type conversion is need. Are there any reasons you would use '==' instead of '==='?
I can think of two.

  * (programmer) laziness

  * if you know you want type coercion
And I just love me some good old fashioned laziness. I mean seriously THREE equals!?
When you know ahead of time that the types don't need to be coerced:

http://jsperf.com/triple-equals-vs-twice-equals/4

There's even a negligible performance improvement, at least for me (iPad WebKit Safari).

For me the "3-equals-true-non-coerced" is the fastest in Chrome 16.
For me the "3-equals-true-non-coerced" is the fastest in Chrome 16.
I don't get it, both on my iPad 2 (iOS 5.0.1) and my MacBook (Firefox 8.0.1) == is several times faster than === which is completely the opposite of what I would be expecting. Perhaps someone who's familiar with the internals of JavaScript JIT compilers could shed some light on it?