> For the complete documentation index, see [llms.txt](https://javascript-1.gitbook.io/javascript/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://javascript-1.gitbook.io/javascript/fp/imperative-vs-declarative.md).

# Imperative vs Declarative

#### Imperative:

It is a code that says the machine, what to do and how to do.

```javascript
Ex:
for (let i = 0; i < 1000; i++) {
    console.log(i);
}
```

#### Declarative:

It is a code that says the machine, what to do and what should happen. It doesn't tell how to do. `Ex: Humans`

```javascript
Ex:
[1, 2, 3].forEach(item => console.log(item));
```

Functional programming is mostly be a declarative, we don't say how to do.
