All JavaScript Passengers, Attention Please
Posted: September 28, 2007 Filed under: javascript, webdev Leave a commentThis is an example why should one follow the rule of using ‘===’ and avoid ‘==’
var a = [];
[!!a, a == false] == [true, true]
You get !!a == true
and at the same time a == false
, now you are confused, ain’t you?
Therefore never ever you should be using in your code ‘==’ operator.
– > Feels better now, ain’t it?
[!!a, a === false] == [true, false]
“Follow the rules” is sometime a rule one should follow