This is a repository to test your understanding of the keyword 'this' in JavaScript.
What determines the value of 'this'?
- determined by how a function is called
- can't be set by assignment during execution
Main patterns:
- global reference (this usually refers to global object)
- free function invocation (global object)
- call/apply (first argument to call/apply)
- method invocation (object on the left of dot, at call time)
- construction mode (new object created for that invocation)
- Fork this repo and clone to your local machine
- Open
src/this.js
. DO NOT OPENspec/thisSpec.js
orSpecRunner.html
YET. - Code your solutions to the problems based on the prompts
- Review your solutions and once you're satisfied, open up
SpecRunner.html
to check your results. - Learn from your results and revisit workshop as necessary.
Author: Shi-Hao Hong (@shihaohong)