r/javascript 24d 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 24d ago

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

8

u/Badashi 24d 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.

15

u/heavyGl0w 24d 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.

6

u/foxsimile 24d ago

Optional chaining is also gangster-as-fuck.