MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/btxz72/what_are_some_javascript_things_beginners_dont/ep5cene?context=9999
r/javascript • u/[deleted] • May 28 '19
383 comments sorted by
View all comments
61
[removed] — view removed comment
28 u/[deleted] May 28 '19 more importantly, understanding the different contexts of this:this in the global space => windowthis in a function => function contextthis in a method of an object => the objectthis with call/apply/bind => whatever you want it to beedit for ES6: this is not bound in arrow functions, so the value bound outside the arrow function will be found and used instead. 5 u/[deleted] May 28 '19 [removed] — view removed comment 7 u/[deleted] May 28 '19 I would guess 2 for the inner log, and 1 for the outer log. Am I mistaken? 5 u/[deleted] May 28 '19 [removed] — view removed comment -1 u/[deleted] May 28 '19 No doubt about it, JS isn’t easy, however, the above list is still accurate and the nuance of the question has to do with IIFE’s, not a different type of ‘this’ binding. → More replies (1)
28
more importantly, understanding the different contexts of this:
this in the global space => window
this in a function => function context
this in a method of an object => the object
this with call/apply/bind => whatever you want it to be
edit for ES6: this is not bound in arrow functions, so the value bound outside the arrow function will be found and used instead.
5 u/[deleted] May 28 '19 [removed] — view removed comment 7 u/[deleted] May 28 '19 I would guess 2 for the inner log, and 1 for the outer log. Am I mistaken? 5 u/[deleted] May 28 '19 [removed] — view removed comment -1 u/[deleted] May 28 '19 No doubt about it, JS isn’t easy, however, the above list is still accurate and the nuance of the question has to do with IIFE’s, not a different type of ‘this’ binding. → More replies (1)
5
7 u/[deleted] May 28 '19 I would guess 2 for the inner log, and 1 for the outer log. Am I mistaken? 5 u/[deleted] May 28 '19 [removed] — view removed comment -1 u/[deleted] May 28 '19 No doubt about it, JS isn’t easy, however, the above list is still accurate and the nuance of the question has to do with IIFE’s, not a different type of ‘this’ binding. → More replies (1)
7
I would guess 2 for the inner log, and 1 for the outer log. Am I mistaken?
5 u/[deleted] May 28 '19 [removed] — view removed comment -1 u/[deleted] May 28 '19 No doubt about it, JS isn’t easy, however, the above list is still accurate and the nuance of the question has to do with IIFE’s, not a different type of ‘this’ binding. → More replies (1)
-1 u/[deleted] May 28 '19 No doubt about it, JS isn’t easy, however, the above list is still accurate and the nuance of the question has to do with IIFE’s, not a different type of ‘this’ binding. → More replies (1)
-1
No doubt about it, JS isn’t easy, however, the above list is still accurate and the nuance of the question has to do with IIFE’s, not a different type of ‘this’ binding.
→ More replies (1)
61
u/[deleted] May 28 '19
[removed] — view removed comment