About 93,500 results
Open links in new tab
  1. How do you use the ? : (conditional) operator in JavaScript?

    Jun 7, 2011 · The conditional (ternary) operator is the only JavaScript operator that takes three operands. This operator is frequently used as a shortcut for the if statement.

  2. javascript - How to write a ternary operator (aka if) expression ...

    Apr 13, 2017 · How to write a ternary operator (aka if) expression without repeating yourself Asked 8 years, 9 months ago Modified 3 years, 3 months ago Viewed 28k times

  3. JavaScript ternary operator example with functions

    The ternary operator is common when you're assigning a value to a variable based on a simple condition or you are making multiple decisions with very brief outcomes. The example you cite …

  4. JavaScript shorthand ternary operator - Stack Overflow

    I know that in PHP 5.3 instead of using this redundant ternary operator syntax: startingNum = startingNum ? startingNum : 1 ...we can use a shorthand syntax for our ternary operators …

  5. Using ternary operators in a function with javascript

    Feb 21, 2019 · If you just pass in the ternary operator, you will end up calling send_command with either your string, or undefined (the return of calling alert () ). However, as an answer to your …

  6. javascript - Using the ternary operator with string concatenation ...

    The + operator causes concatenation with strings and forces all primitive variables to attempt to represent themselves as strings as well. false evaluates as the string "false" creating the …

  7. optimization - Ternary operators in JavaScript without an "else ...

    2 In your case i see the ternary operator as redundant. You could assign the variable directly to the expression, using ||, && operators.

  8. javascript - JS Ternary functions with multiple conditions? - Stack ...

    I have been using a ternary operator in JavaScript to modify the value of an object based on user input. I have the following code, which runs as it should: var inputOneAns = inputOne == "Yes" …

  9. javascript - A somewhat painful triple-nested ternary operator

    May 10, 2012 · 13 If your JavaScript codebase contains nested ternary statements like the one in question, consider converting the formatting to daisy chained ternary statements instead.

  10. Is ternary operator, if-else or logical OR faster in javascript?

    Apr 6, 2010 · Which method is faster or more responsive in javascript, if-else, the ternary operator or logical OR? Which is advisable to use, for what reasons?