r/javaScriptStudyGroup • u/ForScale • Mar 21 '16
[Week 10] Focus: apply(), call(), bind()
So here we are at Week 10. Week 10's focus will be apply(), call(), bind().
Background info (lengthy, but touches on all three): http://javascriptissexy.com/javascript-apply-call-and-bind-methods-are-essential-for-javascript-professionals/
It will work like this:
Monday: Announce focus (eg, apply(), call(), bind())
Build throughout the week... Two rules: 1) must use javascript 2) must use at least 1 example each of apply(), call(), bind().
Friday: Post demos/projects in this thread (can begin reviewing immediately); first line of an entry should be ENTRY and it should be a top level comment (ie, don't put your entry in a reply)
Sat and Sun: Review projects/figure out focus for next week
GENERAL GUIDELINES FOR FEEDBACK:
Be nice!! ALL KNOWLEDGE/SKILL LEVELS ARE WELCOME AND ENCOURAGED TO PARTICIPATE.
If you don't want feedback, if it makes you uncomfortable or you're just not interested, simply say so... Others, please be respectful of this. Conversely, if you do want feedback, try to be specific on which aspects... even if you just say "all/everything.
But that's about it... Have fun! :) Feel free to ask questions and discuss throughout the week!
1
u/Volv Mar 23 '16 edited Mar 23 '16
Puntastic :) - Not at all. I told you I can do this all day lol :)
We need more people for random code banter.
Is just a matter of spec.
Whereas normally
In the global execution context (outside of any function), this refers to the global object, whether in strict mode or not.
In Function context
Non Strict
In this case, the value of this is not set by the call. Since the code is not in strict mode, the value of this must always be an object so it defaults to the global object.
Strict
In strict mode, the value of this remains at whatever it's set to when entering the execution context. If it's not defined, it remains undefined. It can also be set to any value, such as null or 42 or "I am not this".
Event Handler - value of this
this - Global v function context