picture of Josh Dzielak in 2016

Hi! I'm Josh Dzielak, writing here about technology and culture. Find me also on Twitter, Medium, Speakerdeck and Github.

What is 'this'? - Revealing JavaScript's 'this' in different contexts

Understanding the value of ‘this’ in JavaScript as it appears in different contexts is a requisite to becoming an intermediate or advanced JavaScript programmer.

Closures, instantiations, ‘apply’, and ‘with’ all can change what ‘this’ is. Here’s a little guide to help show you how. How many would you have guessed correctly? :)

You can paste the gist into node or your console and you should see the tests pass. If you have some examples to add, fork the gist and add them!