🔰arrow function
(ES6) a new form of function expression.
Last updated
Was this helpful?
(ES6) a new form of function expression.
Last updated
Was this helpful?
Was this helpful?
JS ⟩ value ⟩ function ⟩ arrow function
⭐️ ES6 (2015):a new form of function expression.
a => expression // one statement: {...} optional
(a, b) => expression // multiple params: (...) required
a => { statement1; statement2; } // multiple statements: {...} required
when the { ... }
are omitted, a return value is sent out without using return.
⭐️ (❗️use with caution❗️)
normally, you don't use arrow functions as , but if you have:
aren't suitable for , and methods, which generally rely on establishing a .
don't have access to keyword.
Early Error rule (🚧) is always applied to arrow function definition even if 'strict mode' (🚧) is not defined explicitly.
object B has its own methods,
you don't want this in these methods to refer to B but refer to A instead,
then using arrow functions as methods is an option.
👉 see example: Sequence
can’t be used as constructors. (can’t be called with new)
can’t use yield
, within its body.