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.
[CODE]
the only other thing I may need is PHP to read and write to a database on a server, it seems a shame that javascript cant do that directly?
So PHP can also draw on canvases, creating images that can then be just dropped into an HTML page.
Except for animation, why learn to even use JavaScript? Or why learn to create HTML with PHP? Just use PHP to create images and never learn anything more.
Sorry, but pfui. You remind me of the ranks and ranks of COBOL programmers who never learned anything else and are now stuck doing nothing but maintaining ancient legacy code. Or the steam engine repairmen who refused to learn diesel engines. Or the scribes who refused to learn how to work a printing press. Or...
Learn as much as you possibly can!
I've been programming for over 40 years now, and I *STILL* try to learn something new as often as possible. New languages, new techniques, new tricks for better database efficiency, etc., etc., etc.
__________________
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.
OPendant I agree that it is slightly harder in javascript to increase font size, as you have to set the text style as a string of "font + size pt"
Not logical, should just be a fontsize = number, but still its not that difficult to change with a sting
I dont agree with even the two distinctions of = and ==
That caused me loads of bugs last week before I realised they are completely different
Another stupid idea from someone, who has probably wasted combined millions of hours in errors since
So presumably you would like the PASCAL solution better?
Pascal uses := for assignment and = for comparison.
And it's just as easy there to make the mistake of using = when you meant := as it is to make the JavaScript/Java/C/C++/C#/PHP (and other languages!!!!) mistake of using = when you meant ==.
If you REALLY want confusion, use BASIC, which only has =. And what do you think
Code:
A = B = C = 7
means in BASIC??
HINT: A will get a value of FALSE. Probably.
__________________
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.
OPendant I agree that it is slightly harder in javascript to increase font size, as you have to set the text style as a string of "font + size pt"
Not logical, should just be a fontsize = number, but still its not that difficult to change with a sting
** WRONG **
Yes, your JAVASCRIPT code can COMPLETELY REDRAW the canvas, assuming you code like that and assuming you choose to change the fontsize number.
The BROWSER USER can *NOT* cause that to happen unless you give her/him some way to REQUEST the change in font size.
__________________
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.