# Assignment Operators

In osl you can use an assignment operator to set a variable to itself but modified by an operator. This allows you to compact code into a simpler format.

An example of an assignment operator is `+=` where it adds a number to the variable or joins a string to the variable with a space

```javascript
variable = 10
// the variable is 10

variable += 10
// the variable is now 20
```

## All Assignment operators

```javascript
variable += number
// adds a number to the variable value

variable += string
// joins a string to the variable value with a space

variable -= number
// subtracts a number from the variable value

variable /= number
// divides the variable value by a number

variable *= number
// multiplies the variable value by a number

variable %= number
// sets the varable value to "variable % number"

variable ^= number
// sets the varable value to "variable ^ number"

variable ++= value
// concatonate the value onto the variable
```

## Increment/Decrement

```javascript
variable ++
// increase a variable by exactly 1

variable --
// decrease a variable by exactly 1
```

## Nullish Coalescence

[#nullish-coalescence](#nullish-coalescence "mention")

```javascript
variable ??= 10
// only sets the variable if the variable doesnt exist
```


---

# 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/basics/assignment-operators.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.
