.bind(), .apply() and .call()
常常忘記這三個在幹嘛所以整理一下日後好查詢。
.bind()
|
|
bind doesn’t execute function immediately,
but returns wrapped apply function with certain context (for later execution):
|
|
.apply() / .call()
.call() or .apply() invokes the funciton immediately, and modify the context.
|
|
Notice
Beware that arrow functions could not be bound to another context.
MDN: Arrow function #No binding of this