# Object

URL: https://softwaredictionary.org/terms/object
Category: Programming Fundamentals
Last updated: 2026-10-03
In Turkish: Nesne
Pronunciation: OB-jekt

In short: An object is a bundle of related data and behavior: values in named fields, often called properties, and functions that work on them, called methods.

## What is an object in programming?

Objects let a program model things the way people think about them. A user object might hold a name, an email address and a signup date, and offer methods such as `rename()` or `isActive()`. Instead of passing loose variables around, the code passes one object that keeps its data and the operations on that data together.

In class-based languages such as Java, C#, Python and C++, an object is an instance of a class: the class is the blueprint, and each object made from it has its own copy of the fields. `new User("Ada")` and `new User("Linus")` are two objects of the same class with different data. In JavaScript, objects can also be written directly as literals, `{ name: "Ada" }`, and inherit through prototypes.

Variables usually hold a reference to an object rather than the object itself. Assigning an object to a second variable doesn't copy it: both names point to the same object, so a change through one is visible through the other. Comparing two objects with `==` or `===` in many languages checks whether they are the same object, not whether their contents match.

A common misconception is that objects belong only to object-oriented programming. Functional and procedural code also use objects or records to group data; what makes code object-oriented is organizing it around objects that hide their internal state and expose behavior through methods.

## Key takeaways

- An object groups related data (properties) and behavior (methods).
- In class-based languages an object is an instance of a class.
- JavaScript also has object literals and prototype-based inheritance.
- Variables hold references, so two names can point to the same object.
- Object-oriented code is organized around objects that hide their state.

## Example: Creating objects from a class and as a literal (JavaScript)

```javascript
class User {
  constructor(name) {
    this.name = name;          // a property
    this.createdAt = new Date();
  }
  greet() {                    // a method
    return `Hi, I'm ${this.name}`;
  }
}

const ada = new User("Ada");   // an instance of User
console.log(ada.greet());

const point = { x: 2, y: 3 };  // an object literal
const same = point;            // a second reference, not a copy
same.x = 10;
console.log(point.x);          // 10
```

## Frequently asked questions

**What is the difference between a class and an object?**

A class is the definition: which fields and methods its objects have. An object is one concrete instance made from it, with its own values. One class can produce any number of objects.

**What are properties and methods?**

Properties, also called fields or attributes, are the values an object holds. Methods are the functions that belong to the object and usually read or change those values.

**How do I copy an object?**

Assignment only copies the reference. To get a new object, make a copy explicitly: a shallow copy duplicates the top-level fields, such as `{ ...obj }` in JavaScript, while a deep copy, such as `structuredClone(obj)`, also copies nested objects.

---

Software Dictionary: https://softwaredictionary.org/ · https://softwaredictionary.org/llms.txt
