@babel/plugin-proposal-logical-assignment-operators

Example

In

  1. a ||= b;
  2. obj.a.b ||= c;
  3. a &&= b;
  4. obj.a.b &&= c;

Out

  1. var _obj$a, _obj$a2;
  2. a || (a = b);
  3. (_obj$a = obj.a).b || (_obj$a.b = c);
  4. a && (a = b);
  5. (_obj$a2 = obj.a).b && (_obj$a2.b = c);

Installation

  1. npm install --save-dev @babel/plugin-proposal-logical-assignment-operators

Usage

  1. {
  2. "plugins": ["@babel/plugin-proposal-logical-assignment-operators"]
  3. }

Via CLI

  1. babel --plugins @babel/plugin-proposal-logical-assignment-operators script.js

Via Node API

  1. require("@babel/core").transform("code", {
  2. plugins: ["@babel/plugin-proposal-logical-assignment-operators"]
  3. });

References