Birksy89 Birksy89 - 9 months ago 80
Node.js Question

Using ECMAScript 6 In Node.JS

I'm sure this is a simple one - But I'm learning Javascript and executing programs through Node.js

function sumAll(arr) {

var max = Math.max(...arr);


sumAll([1, 4]);

The error I have is:

SyntaxError: Unexpected token ...

I assume this is down to the ES6 spread operator?
Is this not valid?

I have also tried to add the following, based on other StackOverflow answers I've found:

"use strict";

But this doesn't work either.

Any help appreciated - Thanks

Answer Source

Seems that you use outdated node.js version. Try to update your node.js to the latest version.