-
when
this
is not inside of a declared object its value is the 'window' object (in browser)when
"use strict"
/strict modethis
when inside a function or when a variable is declare inside a function it is undefined in the global obj. -
When
this
is inside of a declared object its value is the closest parent object -
- call -> immediately invoked -> fn.call(thisArg,a,b,c...)
- apply -> immediately invoked -> fn.apply(thisArg,[a,b,c...])
- bind -> returns a function def -> fn.bind(thisArg,a,b,c,d...)-> useful when using asynchronous functions (or functions called later) and when we do not know the exact arguments
-
new
keyword when called will create a new object. Thethis
refers to the new object.