@babel/plugin-proposal-logical-assignment-operators
Example
In
a ||= b;
obj.a.b ||= c;
a &&= b;
obj.a.b &&= c;
Out
var _obj$a, _obj$a2;
a || (a = b);
(_obj$a = obj.a).b || (_obj$a.b = c);
a && (a = b);
(_obj$a2 = obj.a).b && (_obj$a2.b = c);
Installation
npm install --save-dev @babel/plugin-proposal-logical-assignment-operators
Usage
With a configuration file (Recommended)
{
"plugins": ["@babel/plugin-proposal-logical-assignment-operators"]
}
Via CLI
babel --plugins @babel/plugin-proposal-logical-assignment-operators script.js
Via Node API
require("@babel/core").transform("code", {
plugins: ["@babel/plugin-proposal-logical-assignment-operators"]
});