Super duper excited about optional chaining!
One thing I miss from Objective-C that I wish JS would add is the `?:` operator – basically a shortened version of the ternary operator.
One thing I miss from Objective-C that I wish JS would add is the `?:` operator – basically a shortened version of the ternary operator.
true ? console.log("foo") : console.log("bar")
?This is already there: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
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
To get the first user from a server response would be significantly longer if you wrote three nested ternary operators.
?? Short circuits on nullish. Only null and undefined.