In JavaScript, the thing called this, is the object that "owns" the JavaScript code.

The value of this, when used in a function, is the object that "owns" the function.

The value of this, when used in an object, is the object itself.

The this keyword in an object constructor does not have a value. It is only a substitute for the new object.

The value of this will become the new object when the constructor is used to create an object.

Note that this is not a variable. It is a keyword. You cannot change the value of this.

Built-in JavaScript Constructors

JavaScript has built-in constructors for native objects:

Example

var x1 = new Object(); // A new Object objectvar x2 = new String(); // A new String objectvar x3 = new Number(); // A new Number objectvar x4 = new Boolean() // A new Boolean objectvar x5 = new Array(); // A new Array objectvar x6 = new RegExp(); // A new RegExp objectvar x7 = new Function(); // A new Function objectvar x8 = new Date(); // A new Date object