Journey of Nullish coalescing operator (?? 😮)

  • a if it’s not null or undefined,
  • b, otherwise.
x = (a !== null && a !== undefined) ? a : b;
  • || returns the first truthy value.
  • ?? returns the first defined value.
money = money ?? 100;

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhishek Saxena

Abhishek Saxena

Working as a full time Front-End developer & also searching web for some cool stuff.