property

A named value belonging to an object; in languages such as C# and Python, it can also be a member that looks like a field but runs code when read or written.

In more detail

Properties let a type expose data while controlling how it is read and written. In JavaScript, a property whose value is a function is called a method, and properties can be added, changed and deleted at run time. Frameworks often discover properties automatically, for example to serialise objects to JSON.

Examples

public decimal Price { get; set; }
public int Units { get; private set; }
V8 remembers the order in which properties were added as an object's hidden class, so adding them in the same order keeps code fast.
In Python, a method marked @property is read like an attribute: rect.area instead of rect.area().

Related terms

Taught in

References