this
noun
say it: “THIS” /ðɪs/
A word that, inside a regular function, means the object the function was called on: the object before the dot.
What is this in JavaScript?
this — A value supplied by the way a regular function is called, often referring to the receiving object.
const order = {
quantity: 2,
describe() {
return `${this.quantity} items`;
}
};
In a sentence
- “Inside the describe method, this is the pet before the dot, so mochi.describe() uses Mochi's name.”
Level: Apprentice · More JavaScript terms at this level
Updated