In
var a = ['a', 'b', 'c'];
var b = [...a, 'foo'];
Out
var a = [ 'a', 'b', 'c' ];
var b = [].concat(a, [ 'foo' ]);
npm install --save-dev babel-plugin-transform-es2015-spread
.babelrc
(Recommended).babelrc
Without options:
{
"plugins": ["transform-es2015-spread"]
}
With options:
{
"plugins": [
["transform-es2015-spread", {
"loose": true
}]
]
}
babel --plugins transform-es2015-spread script.js
require("babel-core").transform("code", {
plugins: ["transform-es2015-spread"]
});
loose
boolean
, defaults to false
.
In loose mode, all iterables are assumed to be arrays.