It's a sugary anon function with some key differences.
(params) => { code }
- No need for the
function
keyword - No need for
{}
if the function is only a single line - Single arguments (except
rest
args) don't need()
but 0 args do return
is implicit with single line functions
- Lexical
this
- the most important; unlike a function, it does not define its ownthis
value, it uses the enclosing context'sthis
. - Lexical arguments - they share the arguments object of the enclosing scope.
rest
parameters can be used as an alternative. - They can't be used as generators or constructors; may have unexpected effects when used as methods; etc...