> 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/oop.md).

# OOP

Object Oriented Programming

#### OOP:

* this
* new keyword
* Prototype
* Classes
* Inheritance
* Object.Create()
* Private vs Public
* 4 principles of OOP.

```javascript
Ex:
const dragon = {
    name: 'tanya',
    fire: true,
    fight() {
        return 5;
    },
    sing() {
        if (this.fire) {
            return `I'm ${this.name}, the breather of fire`;
        }
    }
};
```

In the above example, name and fire allows to track the state of the object and fight and sing methods allows us to manipulate the state of the object.

There are two object oriented programming in JavaScript.

1. Prototypal Object Oriented Programming
2. Class Object Oriented Programming

Reference's:

{% embed url="<https://www.geeksforgeeks.org/introduction-object-oriented-programming-javascript/>" %}

{% embed url="<https://alistapart.com/article/prototypal-object-oriented-programming-using-javascript/>" %}

{% embed url="<https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object-oriented_JS>" %}
