#Arrow functions
setTimeout(() => {
···
})
#with parameters
readFile('text.txt', (err, data) => {
...
})
#implicit return
arr.map(n => n*2)
//no curly braces = implicit return
//Same as: arr.map(function (n) { return n\*2 })
arr.map(n => ({
result: n*2
}))
//Implicitly returning an object requires parentheses around the object
Like a function, but preserves this
.
See: Arrow functions
Comments