@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
Via .babelrc (Recommended)
.babelrc
{
"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"]
});