MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/1v3e7eb/askjs_whats_a_javascript_feature_you_massadopted/oz61owb/?context=3
r/javascript • u/Capedcrusader1923 • Jul 22 '26
107 comments sorted by
View all comments
68
The nullish coalescing operator is one of JavaScript’s unusual successes.
8 u/Badashi Jul 22 '26 At first it was odd to look at it, specially for optional function calls (foo?.()), but it is a godsend. Having to work on a language without null coalescing is super weird now. 15 u/heavyGl0w Jul 22 '26 Just FYI, what you're describing is optional chaining.Null coalescing is a related but different feature using the ?? operator. It evaluates the right hand operand only when the left is null or undefined. 5 u/foxsimile Jul 23 '26 Optional chaining is also gangster-as-fuck.
8
At first it was odd to look at it, specially for optional function calls (foo?.()), but it is a godsend. Having to work on a language without null coalescing is super weird now.
foo?.()
15 u/heavyGl0w Jul 22 '26 Just FYI, what you're describing is optional chaining.Null coalescing is a related but different feature using the ?? operator. It evaluates the right hand operand only when the left is null or undefined. 5 u/foxsimile Jul 23 '26 Optional chaining is also gangster-as-fuck.
15
Just FYI, what you're describing is optional chaining.
Null coalescing is a related but different feature using the ?? operator. It evaluates the right hand operand only when the left is null or undefined.
??
null
undefined
5 u/foxsimile Jul 23 '26 Optional chaining is also gangster-as-fuck.
5
Optional chaining is also gangster-as-fuck.
68
u/foxsimile Jul 22 '26
The nullish coalescing operator is one of JavaScript’s unusual successes.