CKTIS / JavaScript
this — a value determined by the calling context
The `this` keyword reads the current `this` binding. In an ordinary function its value depends on how the function is called, while an arrow function uses the enclosing binding. Storing a function in an object does not permanently bind it to that object.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
this
this.property
this[expression]this is a keyword and an expression, not an ordinary variable or the function's name. It reads the current this binding; you cannot assign to it with this = value. It does not necessarily refer to an object.
For an ordinary, unbound function, obj.method() supplies obj as this. After const f = obj.method, calling f() does not retain that receiver. Inside a strict-mode function, this is then undefined; in non-strict mode, undefined and null are replaced with the global this value, and primitive values are wrapped in objects.
call and apply supply an explicit this, while bind creates a function with a bound this for ordinary calls. An arrow function has no own this binding: it uses its enclosing environment, so these methods cannot change it. Storing an arrow as an object property does not give it that object as this.
With new, an ordinary constructor receives a new object as this. In a derived class constructor, accessing this before super() is not allowed. At module top level, this is undefined; in a plain script it is the global this value. Do not automatically extend that assumption to modules wrapped by the host environment.
The example demonstrates a method receiver, its loss when the function is detached, explicit selection through call, and an arrow's lexical this. It uses ECMAScript 2015 syntax and requires no browser APIs.
Examples
"use strict";
const box = {
value: 7,
read() {
return this === undefined ? "no receiver" : this.value;
},
makeReader() {
return () => this.value;
}
};
const detached = box.read;
const reader = box.makeReader();
console.log(box.read());
console.log(detached());
console.log(detached.call({ value: 9 }));
console.log(reader.call({ value: 99 }));Result
7 no receiver 9 7
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.