This is the happening place to discuss all things related to the If and Else Statements in JS tutorial.
Please add some notes on triple equal '==='.
I want triple equals .Originally Posted by Crockford
Does ternary operator includes here? Or that can be another tutorial on conditionals.
Here's another case where I disagree with Crockford. I know exactly how == and === differ, have known for years, and still find that == is almost always what I want and intend. However, I wouldn't try to convince people to use one over the other like he has (in my opinion, unfortunately) done.
Nope, I'm just disagreeing with this one piece of his advice. (I said 'another' because there was another of his pieces of advice mentioned recently in a different thread.) I'm not saying anything as sensational as you're implying.
Maybe it's good to point out that there are ways to write 'if' and 'if/else' statements using shorter syntax.
Not that I recommend to use them, as they are hard to read, but it's a good thing to know what these statements do...
A few examples:
Short IFCode:if (variable_1 == 80) alert("something");
Short ORCode:(variable_1 == 80) && alert("something");
Short if/elseCode:variable_1 = some_property || 0;
Short if/elseCode:alert( (variable_1==80) ? 'eighty' : 'not eighty' );
Code:variable_1 = some_property ? 1 : 0;
I think it would make sense to say in this tutorial that the condition for an if statement doesn't necessarily need to be a comparison between two operands. It can be any expression that evaluates to a boolean. It would then probably make sense to say what different literal values and complex objects resolve to when coerced.
We tolerate living and breathing. And niches.
Name Brand Watches
Maybe getTimer() or TweenMax is the answer to your problem . . .
It can be any expression. And any expression can be evaluated and converted to be a boolean value. (This might have been exactly what you were saying in your post, but the way that I read your post seemed to imply that there are some expressions that you couldn't use in an if statement.)Originally Posted by TheCanadian
I agree that the additional explanation that you suggested for the tutorial would be useful.
I interpret his tone in the same way!Originally Posted by TheCanadian
There are currently 1 users browsing this thread. (0 members and 1 guests)