Best part of the post:
When working with
this, remember the following rules:- It’s set based on how a function is called:
new MyConstructorormyObject.method()will refer to an instance, whilethisinside a function refers to the global context - Strict mode causes
thisto evaluate toundefinedinstead of the global context inside functions thiscan be referenced by a variable, andselfis the conventionally used name