JavaScript this
keyword refers to the current object. In other words, while executing every JavaScript function has a reference to its current execution context, known as this
. In simple, here execution context means how the function is called. JavaScript this
has different values depending on where it is used-
Global Context:-
Object's Method:-
The call(), apply() and bind() Method:-
The new
keyword is used to create an instances of objects from a constructor function, which has to be placed before the constructor function call and will do the following-
function TutorialsLogic (tutorial) {
this.tutorial = tutorial;
}
const website = new Dog(12);
console.log(website); //
console.log(website.__proto__ === TutorialsLogic.prototype) // true