UberRose
UberRose

Reputation: 86

Nullish coalescing javascript operator not working in edge

When I use the ?? javascript operator in Edge, I'm getting a syntax error. For instance, typing the following in the console in Chrome and Firefox works, but it gives a syntax error in Edge.

false ?? 1

Expected result: false

null ?? 1

Expected result: 1

As I said, this works Chrome and Firefox but results in a syntax error in Edge. Any ideas what I'm doing wrong? MDN says Edge supports ??.

Upvotes: 0

Views: 2056

Answers (1)

Yu Zhou
Yu Zhou

Reputation: 12961

Edge Legacy doesn't support Nullish coalescing operator. You could check the MDN Browser compatibility and caniuse. It's only supported by Microsoft Edge version 80+.

If you want to use Nullish coalescing operator in Edge Legacy, you could use Babel to transpile it.

Reference plugin: @babel/plugin-proposal-nullish-coalescing-operator

Upvotes: 1

Related Questions