Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 943 Bytes

README.md

File metadata and controls

25 lines (19 loc) · 943 Bytes

'this' Keyword Workshop

This is a repository to test your understanding of the keyword 'this' in JavaScript.

Pointers

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)

How to use repo:

  1. Fork this repo and clone to your local machine
  2. Open src/this.js. DO NOT OPEN spec/thisSpec.js or SpecRunner.html YET.
  3. Code your solutions to the problems based on the prompts
  4. Review your solutions and once you're satisfied, open up SpecRunner.html to check your results.
  5. Learn from your results and revisit workshop as necessary.

Author: Shi-Hao Hong (@shihaohong)