Skip to content

Latest commit

 

History

History
22 lines (19 loc) · 7.17 KB

File metadata and controls

22 lines (19 loc) · 7.17 KB

Keywords

Understanding the this Keyword in JavaScript 7/14/24
//reserved words
break case catch class const continue debugger default
delete do else enum export extends false finally for
function if implements import interface in instanceof let
new package private protected public return static super
switch this throw true try typeof var void while with yield
instanceof The instanceof operator tests whether the prototype property of a constructor appears anywhere in the prototype chain of an object.
new The new operator lets developers create an instance of a user-defined object type or of one of the built-in object types that has a constructor function. The new keyword does the following things:
this

A function's this keyword behaves a little differently in JavaScript compared to other languages. It also has some differences between strict mode and non-strict mode.

In most cases, the value of this is determined by how a function is called (runtime binding). It can't be set by assignment during execution, and it may be different each time the function is called. ES5 introduced the bind() method to set the value of a function's this regardless of how it's called, and ES2015 introduced arrow functions which don't provide their own this binding (it retains the this value of the enclosing lexical context).