Default Values for Function Parameters in ES6

Share this video with your friends

Send Tweet

With ECMAscript 6 we get the luxury of default parameters for our functions.

Haitao.Huang
Haitao.Huang
~ 8 years ago

I run the code , but there is SyntaxError:

/usr/local/Cellar/node/5.6.0/bin/node --use-strict /Users/huanghaitao/WebstormProjects/es6/default.js /Users/huanghaitao/WebstormProjects/es6/default.js:5 let receive = (complete = () => console.log("complete")) => complete() ^

SyntaxError: Unexpected token = at exports.runInThisContext (vm.js:53:16) at Module._compile (module.js:387:25) at Object.Module._extensions..js (module.js:422:10) at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12) at Function.Module.runMain (module.js:447:10) at startup (node.js:140:18) at node.js:1001:3

Process finished with exit code 1

the config not right?

Mher
Mher
~ 8 years ago

you don't have es6 enabled.

Mike
Mike
~ 8 years ago

Love the one liner at the end.

Venkata Janapareddy
Venkata Janapareddy
~ 8 years ago

Could you please tell me how you are running app.js in the built in terminal? Thanks

Sina
Sina
~ 8 years ago

Press the green "play" button, or Shift+F10 ( in case of webStorm)