# Object Operations

## Basic Operations

Objects in OSL provide various ways to access and modify their properties:

```javascript
obj = {x: 1, y: 2}

// Accessing properties
val1 = obj.x          // Using dot notation
val2 = obj["x"]       // Using bracket notation

// Modifying properties
obj.x = 10            // Using dot notation
obj["x"] = 10         // Using bracket notation
```

## Object Methods

```javascript
// Getting object information
keys = obj.getKeys()      // Returns array of keys
values = obj.getValues()  // Returns array of values

// Checking for properties
exists = obj.contains("x")  // Returns true/false
```

## Object Merging

The `++` operator combines objects, preserving values from the left operand:

```javascript
obj1 = {a: 1, b: 2}
obj2 = {b: 3, c: 4}
merged = obj1 ++ obj2    // {a: 1, b: 2, c: 4}

// Multiple merges
final = obj1 ++ obj2 ++ {d: 5}
```

## Using Self Reference

Objects can reference their own properties using `self`:

```javascript
calculator = {
    base: 100,
    tax: 0.2,
    total: self.base * (1 + self.tax),
    calculate: def() -> (
        return self.base * (1 + self.tax)
    )
}
```

## Computed Properties

Objects can include computed values when created:

```javascript
multiplier = 2
price = 10

product = {
    base: price,
    doubled: price * multiplier,
    withTax: self.base * 1.2
}
```

## Important Notes

* Properties can be accessed using dot or bracket notation
* The `++` operator preserves left operand values in conflicts
* Use `self` to reference object's own properties
* `.contains()` checks for property existence
* `.getKeys()` and `.getValues()` return arrays
* Computed properties are evaluated at creation time
* Objects can contain methods using `def() ->`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://osl.mistium.com/arrays-and-objects/object-operations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
