MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › Conditional_operator
Conditional (ternary) operator - JavaScript | MDN
The conditional (ternary) operator is the only JavaScript operator that takes three operands: a condition followed by a question mark (?), then an expression to execute if the condition is truthy followed by a colon (:), and finally the expression to execute if the condition is falsy.
Videos
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › Nullish_coalescing
Nullish coalescing operator (??) - JavaScript | MDN
The nullish coalescing operator can be seen as a special case of the logical OR (||) operator. The latter returns the right-hand side operand if the left operand is any falsy value, not only null or undefined. In other words, if you use || to provide some default value to another variable foo, ...
GeeksforGeeks
geeksforgeeks.org › javascript-ternary-operator
JavaScript Ternary Operator | GeeksforGeeks
The ternary operator allows you to quickly decide between two values depending on whether a condition is true or false. ... Condition: A condition that evaluates to true or false. expressionIfTrue: The value or expression is returned if the ...
Published April 15, 2025
vteams
vteams.com › blog › what-is-question-mark-in-javascript
Javascript's Double Question Mark: Meaning and Usage
April 23, 2024 - The ternary operator is basically a shortcut for a traditional if…else statement. Let’s compare JavaScript ternary if, with traditional if…else statement: ... As you can see, the JS question mark operator is only taking one line whereas if…else statement is taking a couple of lines.
Scaler
scaler.com › home › topics › what is a nullish coalescing operator or double question mark (??) in javascript?
What is JavaScript double question mark (??) - nullish coalescing operator - Scaler Topics
March 28, 2024 - Javascript double question mark is a logical operator that takes two values and returns the right-hand value if the left-hand value is undefined or null, else returns its left-hand value.
SkillReactor Blog
skillreactor.io › home › double question mark javascript operator explained
Double Question Mark JavaScript Operator Explained - SkillReactor Blog
July 8, 2024 - The double question mark operator, denoted by ??, is often used in conjunction with nullish coalescing to provide a fallback value in case a variable is either null or undefined. It simplifies the code by reducing the need for multiple checks or ternary operators.
Top answer 1 of 2
3
It's called the Short-circuit evaluation and it's a feature of TypeScript. Not JavaScript .
When whatever before ? Is null or undefined, whatever after ?. Won't be called.
That's to avoid errors like: undefined has no property removeEventListener
Edit
I was wrong when I said it's not a feature of JavaScript. It's actually a new feature. Some browsers that are not updated to the latest don't support it yet (like mine)
2 of 2
3
Optional chaining (?.) The optional chaining operator (?.) enables you to read the value of a property located deep within a chain of connected objects without having to check that each reference in the chain is valid.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
JavaScript.info
javascript.info › tutorial › the javascript language › javascript fundamentals
Nullish coalescing operator '??'
The nullish coalescing operator is written as two question marks ??.
Aaccsc
aaccsc.com › calcium-bromide › javascript-double-question-mark-operator.html
Javascript double question mark operator
The basic form of a ternary expression is code amp lt expression amp gt amp lt truthy expression amp gt amp lt falsey expressio left pointing double angle quotation mark left pointing guillemet inverted question mark turned question mark asterisk operator Checking for boolean values is easy in JavaScript they are going to be either true or false and typeof a boolean is always quot boolean quot .
freeCodeCamp
freecodecamp.org › news › the-ternary-operator-in-javascript
JavaScript Ternary Operator – Syntax and Example Use Case
January 6, 2023 - Let's see how to do this with the ternary operator: const score = 60 const scoreRating = score > 70 ? "Excellent" : score > 50 ? "Average" : "Do better" console.log(scoreRating) // "Average" Here, you see we have two question marks and two colons. In the first ternary operator, we have the conditional expression score > 70.