HN user

richyliu

23 karma
Posts0
Comments5
View on HN
No posts found.
Node.js 15.0 6 years ago

Here's more information on the 3 new logical assignments

Logical OR assignment (||=) [1] Logical AND assignment (&&=) [2] Logical nullish assignment (??=) [3]

An example for OR assignment:

  let a = '';
  a ||= 'hello';
  console.log(a); // prints 'hello'
  a ||= 'not this';
  console.log(a); // prints 'hello'
[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... [2]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... [3]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...