With ECMAscript 6 we get the luxury of default parameters for our functions.
There's no general reason not to use arrow functions. But arrow functions are anonymous functions, so everything that applies to anonymous functions also applies to arrow functions.
You should generally avoid anonymous functions except for very trivial code. Anonymous functions leave less helpful stack traces and it's more difficult to understand their intent.
Additionally arrow functions are always bound to the current
this, so they may not actually do what you want. For example, when defining an ES5-style "class" (i.e. constructor function with a
prototype property), you explicitly want
this to be unbound, so arrow functions won't give you what you want.
In my opinion, arrow functions are useful where-ever you would normally use anonymous functions and either don't care about
this or would otherwise use
Function.prototype.bind or a local variable.
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
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)
Process finished with exit code 1
the config not right?