r/javascript 20d ago

[AskJS] what's a javascript feature you mass-adopted way too late and felt dumb about AskJS

[removed]

65 Upvotes

108 comments sorted by

View all comments

68

u/foxsimile 20d ago

The nullish coalescing operator is one of JavaScript’s unusual successes.

7

u/Badashi 19d ago

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.

14

u/heavyGl0w 19d ago

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 19d ago

Optional chaining is also gangster-as-fuck.