Can you bind 'this' in an arrow function ?
Bind 'this' in arrow function Javascript
'This' keywork in arrow function Javascript
Rebind 'this' in arrow function
Context of arrow function
Cannot bind 'this' in arrow function
You cannot rebindthis
in an arrow function. It will always be defined as the context in which it was defined. If you requirethis
to be meaningful you should use a normal function.
Differences & Limitations of Arrow function vs Normal function:
- Does not have its own bindings to
this
orsuper
, and should not be used asmethods
. - Does not have
arguments
, ornew.target
keywords. - Not suitable for
call
,apply
andbind
methods, which generally rely on establishing ascope
. - Can not be used as
constructors
. - Can not use
yield
, within its body
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
https://stackoverflow.com/questions/33308121/can-you-bind-this-in-an-arrow-function
Nhận xét
Đăng nhận xét