Nullish Coalescing Assignment Operator (??=) In Nodejs
I'm trying to use the Nullish coalescing assignment operator (??=) in NodeJS, it is possible? const setValue = (object, path, value) => { const indices = { first: 0,
Solution 1:
The error means your version of Node does not yet have support for the ??=
operator.
Check out the versions which support it on node.green:
Solution 2:
It's possible for node version v15.14+.
The rewrite for something like
a.greeting ??= "hello"
in node <v15.14 is:
a.greeting = a?.greeting ?? 'hello'
Maybe it does help someone :]
Solution 3:
The node version you are using doesn't support the nullish coalescing assignment operator.
Solution 4:
You could replace logical nullish assignment ??=
o[k] ??= isFinite(i + 1in kk ? kk[i + 1] : last) ? [] : {}
with an assignment with logical OR ||
o[k] = o[k] || (isFinite(i + 1in kk ? kk[i + 1] : last) ? [] : {})
Post a Comment for "Nullish Coalescing Assignment Operator (??=) In Nodejs"