DEV Community

Discussion on: JavaScript: Latest Stage-4 features

Collapse
 
ojoaofernandes profile image
João Fernandes

Motivation

Convenience operators, inspired by Ruby's. We already have a dozen mathematical assignment operators, but we don't have ones for the often used logical operators.

function example(a) {
  // Default `a` to "foo"
  if (!a) {
    a = 'foo';
  }
}

A proposal to combine Logical Operators and Assignment Expressions:

// "Or Or Equals" (or, the Mallet operator :wink:)
a ||= b;
a || (a = b);

github.com/tc39/proposal-logical-a....