3 ms·
'===' faster than '=='?
- 1p1e1 15y ago'===' performs better than '==' because no type conversion is need. Are there any reasons you would use '==' instead of '==='?
- ryanbraganza 15y agoI can think of two. * (programmer) laziness * if you know you want type coercion
- lucisferre 15y agoAnd I just love me some good old fashioned laziness. I mean seriously THREE equals!?
- zachrose 15y agoWhen you know ahead of time that the types don't need to be coerced: http://jsperf.com/triple-equals-vs-twice-equals/4 http://jsperf.com/triple-equals-vs-twice-equals/4 There's even a negligible performance improvement, at least for me (iPad WebKit Safari).
- kenneth_reitz 15y agoShouldn't this be obvious?
- DrJokepu 15y agoI 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?