I want to know if the two JavaScript snippets are the same or not
coding-style, javascript
Solution
Answer: the result, which is the alert box, will be the same.
Explanation:
Most languages are designed to evaluate the second expression only if the first one evaluated to `true`, in case of an `&&` expression.
This means that if `a` evaluates to `false`, `null`, `undefined`, an empty string, `0`, or `NaN`, `alert("a is true")` won't be evaluated, and you won't see the alert box.
JavaScript has values which can be "truthy" or "falsy", I suggest you read more about that here: http://11heavens.com/falsy-and-truthy-in-javascript.
So, it depends on your definition of "same", the result, i.e. seeing or not seeing the alert box, is the same.
If you want to know more about different operators in JavaScript, and how they work, check out: developer.mozilla.org/en-US/docs/JavaScript/Guide/Expressions_and_Operators.
Problem
I am new to JavaScript and I want learn more about it. For example: ``` a == true && alert("a is true"); ``` Is this similar to: ``` if(a == true) { alert("a is true"); } ``` If the above code is correct and if they both are equal, then I want to know all operators and conditions like this. Where can I find them?