About 50 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 ternary operator example with functions

    Possible duplicate of using ternary operator in javascript to invoke two functions?

  3. 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, 10 months ago Modified 3 years, 4 months ago Viewed 28k times

  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 where …

  5. Javascript nested ternary operator - Stack Overflow

    Javascript nested ternary operator Asked 8 years, 7 months ago Modified 10 months ago Viewed 17k times

  6. 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.

  7. javascript - How do I check truthy when using Ternary Operator - Stack ...

    Feb 27, 2024 · I am having issues with using the ternary operator and checking if a value is truthy or not. I have a feeling that my syntax is incorrect. Below is the instructions on what I need to do to pass thi...

  8. Ternary operator with return statements JavaScript

    Oct 18, 2013 · Ternary operator with return statements JavaScript [duplicate] Asked 12 years, 3 months ago Modified 7 years, 9 months ago Viewed 111k times

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

    In JavaScript, the + operator has higher precedence than the ?: operator. This means that concatenation will take place before the condition in a ternary is evaluated.

  10. conditional operator - Javascript one line If...else...else if ...

    Mar 13, 2015 · Ternary operator ?: used as inline if-else is right associative. In short this means that the rightmost ? gets fed first and it takes exactly one closest operand on the left and two, with a :, on the …