Reputation: 63
i am playing with spread syntax on node/browser.
console.log([{ name: "herry" }, { age: "10" }].reduce((acc, cur) => ({...cur,...acc})))
1) with nodejs v6.10,
SyntaxError: Unexpected token ...
2) Chrome 50
SyntaxError: Unexpected token ...
3) babel stage-0, it's working well.
I am just wandering why it's not working on node 6.10 since it's all green for spread op.
Upvotes: 1
Views: 851
Reputation: 21
To get this working:
yarn add -D babel-plugin-transform-object-rest-spread # (or the npm equivalent)
Then add "transform-object-rest-spread" to your .babelrc plugins e.g.
{
"presets": ["es2015"],
"plugins": ["transform-object-rest-spread"]
}
Upvotes: 2