Thread: Canvas Problem
View Single Post
Old 12-05-2012, 01:03 AM   PM User | #17
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,210
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
I have to admit that I would never bother to use === for something like this:
Code:
			if(tileTopCount===map[x].length){
I mean, we *KNOW* that both of those values are numbers. The one because we made it so, the other because the .length property is guaranteed to be so.

So why do we need to test that the types are equal?

If JavaScript were more sensitive to what === means, I might be more inclined to use it. For example, if === distinguished between integers and non-integers. But it doesn't, because JavaScript doesn't see a distinction between them.

I commonly only use === when I'm comparing against something being returned by some function and where I can't guarantee the type being returned.

Still, it's a nice operator to have in your arsenal.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote