# OOP vs FP

#### OOP:

1. Organizing a code into a unit.
2. Grouping things into a box, known as states and action performed is methods.
3. Objects are the first class citizens.&#x20;
4. Principles are Abstraction, Encapsulation, Inheritance and Polymorphism.
5. Few operations on common data.
6. State can be modified (mutable).
7. Has side effects.
8. Imperative.

#### FP:

1. Avoiding side effects and writing pure functions.
2. Combination of data is functions. The result will be based on the input data without any side effects and is immutable.
3. Functions are first class citizens.
4. It all around the pure function and compose.
5. Many operations on fixed data.
6. State is immutable.
7. Pure and no side effects.
8. Declarative.


---

# 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://javascript-1.gitbook.io/javascript/oop-vs-fp.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.
