Strictly speaking, they will produce the same results, but if you use the former case as a condition for something else, you will get dissimilar results. This is because in the case of x && doSomething()
, doSomething()
will return a value to signify its success.
More Related Contents:
- “elseif” syntax in JavaScript
- Using a block’s return value in JavaScript
- JavaScript Syntax error
- Javascript if statement says 63>542 is true
- Location of parenthesis for auto-executing anonymous JavaScript functions?
- What do parentheses surrounding an object/function/class declaration mean? [duplicate]
- How does this JavaScript/jQuery syntax work: (function( window, undefined ) { })(window)?
- What does the leading semicolon in JavaScript libraries do?
- Why avoid increment (“++”) and decrement (“–“) operators in JavaScript?
- How do I convert a float number to a whole number in JavaScript?
- Javascript: Get deep value from object by passing path to it as string [duplicate]
- How do I test if a variable does not equal either of two values?
- How can I concatenate regex literals in JavaScript?
- Javascript Property with three dots (…)
- When to use the double not (!!) operator in JavaScript
- No semicolon before [] is causing error in JavaScript
- When should I use a semicolon after curly braces?
- Use of commas versus semicolons?
- JavaScript error (Uncaught SyntaxError: Unexpected end of input)
- Function and variable with the same name
- Nested JSON objects – do I have to use arrays for everything?
- How can % signs be used in identifiers
- Javascript while loop return value
- How to use OR condition in a JavaScript IF statement?
- JavaScript single line ‘if’ statement – best syntax, this alternative? [closed]
- How to fire jQuery function only if form is valid
- How to toggle a boolean?
- How to negate code in “if” statement block in JavaScript -JQuery like ‘if not then..’
- Unnecessary ‘else’ after ‘return’. (No-else-return)
- how to compare two strings in javascript if condition