JavaScript OOPS – Object Oriented Programming System
📘 What is OOPS?
- OOPS stands for Object Oriented Programming System.
- In simple words, OOPS is a way of writing code where we group data and functions together using objects.
👉 OOPS helps us write clean, organized, and reusable code.
🔹 Why Use OOPS in JavaScript?
✅ Code becomes easy to manage
✅ Reusability of code
✅ Better structure
✅ Used in real-world projects
✅ Makes applications scalable
🔹 What is an Object?
- An object is a real-world entity.
Example:
- Car
- Student
- User
Example Object in JavaScript
let user = {
name: “Shivam”,
age: 21
};
🔹 What is a Class?
- A class is a blueprint of an object.
- In simple words, a class defines how an object will look and behave.
Example Class in JavaScript
class User {
constructor(name, age) {
this.name = name;
this.age = age;
}
}
🔹 What is Constructor?
- A constructor is a special function that runs automatically when an object is created.
Constructor Example
class User {
constructor(name) {
this.name = name;
}
}
let u1 = new User(“Shivam”);
🔹 What is Inheritance?
- Inheritance means one class uses properties of another class.
👉 Child class inherits from parent class.
Inheritance Example
class Person {
greet() {
console.log(“Hello”);
}
}
class Student extends Person {}
let s1 = new Student();
s1.greet();
🔹 What is Encapsulation?
- Encapsulation means hiding data and showing only required information.
- It helps protect data.
- (Simple explanation is enough for beginners)
🔹 What is Polymorphism?
- Polymorphism means same function name, different behavior.
- It improves flexibility in code.
🔹 Advantages of JavaScript OOPS
- Cleaner code
- Easy debugging
- Reusable components
- Better project structure
📌 Conclusion
- JavaScript OOPS helps us write professional-level code.
- Using:
- Class
- Object
- Constructor
- Inheritance



