What is this keyword in JavaScript?

Answer:

  • Refers to the current execution context.
  • In global → this is window (in browsers).
  • Inside objects → refers to that object.

Example:

let person = {
  name: "Ali",
  greet: function() {
console.log("Hello " + this.name);
} }; person.greet(); //

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *