mirror of
https://github.com/bendtherules/blog-hashnode-backup.git
synced 2026-08-18 13:42:04 +00:00
update post: What is this inside foo.bar()?
This commit is contained in:
@@ -48,7 +48,7 @@ One example of this is rewriting `foo.bar()` using a intermediate variable - ` f
|
|||||||
|
|
||||||
So, if `bar` was referencing other values from foo using `this`, those values will become undefined or resolve to a wrong variable.
|
So, if `bar` was referencing other values from foo using `this`, those values will become undefined or resolve to a wrong variable.
|
||||||
|
|
||||||
🧠 This is exactly the reason why passing methods as callback changes the value of `this` (passed within it). Instead of calling a method directly, callback is passed as a function and called later by some other code.
|
🧠 This is exactly the reason why passing methods as callback changes the value of `this` (passed within it). Instead of calling a method directly, callback is actually passed as a function and this function is later called by some other code.
|
||||||
|
|
||||||
## In other words,
|
## In other words,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user