Do you mean
true ? console.log("foo") : console.log("bar")
?This is already there: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
true ? console.log("foo") : console.log("bar")
?This is already there: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
To get the first user from a server response would be significantly longer if you wrote three nested ternary operators.
x ?: y
is shorthand for x != null ? x : yx || y
For example in PHP, it works exactly like you describe.
You can write x ?? y
Which is x !== null and x != undefined ? x : y