So this is the introduction of object oriented programming in JavaScript.
It was known as OOP.
OOP stands for Object Oriented Programming and it was introduced in ES6 version of JavaScript.
Object oriented programming is a coding methodology or a style or a pattern.
It is introduced to convert our big line of code into a smaller line of code.
With this, we can make our code more modular and reusable that we can use that code over and over again.
It makes our code well organized, and let's make our code very easier to debug.
Debug.
I mean, if there is an error in our code and the method, the catching the error is called debug.
Basically, we do not use object oriented programming for small task.
It is used for big and complex projects.
It is currently used in various JavaScript framework like React.js, AngularJS, Vue.js and these are
all based on modern JavaScript.
If you want to understand object oriented programming, first you need to understand two terms.
First one is class and second one is object.
If you understand these two concepts, then you understand 50% of object oriented programming and the
OOP concept used in every high level programming language.
So at first let's try to understand what is class and objects.
Let's try to explain it with graphical images.
Suppose we have a blueprint of a building and a builder build houses with this blueprint.
So according to the blueprint, every building the builder make is similar.
All building designs are identical.
As you can see, the blueprint has three bedrooms and one kitchen, so every building is pretty similar.
So we can accept our blueprint as a class.
And all the buildings made by this blueprint are objects.
The point is, objects are made with this class.
Let me show you another example and it little advance.
Suppose we have a class named car and these are two actual cars.
First one is Maruti Swift and second one is Toyota Fortuner.
So we create a class named car.
And our actual cars are objects which is made by the car class.
And as you know, every car have some common properties like their color engine seat, their AC and
their prices.
We call them properties in programming language and these properties are associated with one or more
classes.
Every class have their own property.
As you can see, we have two actual cars, Swift and Fortuner.
Their properties are same, but their value is different.
As you can see Maruti have four color option but Toyota have five color option.
Maruti provide 1200 cc engine and Toyota provide 2700 cc engine.
Maruti provide five seat and Toyota provide seven seat and both the car provide SC and also you can
see there is huge price difference between these two.
Car properties are basically a variable and we can set different value for this variable.
And if you want to change and manipulate the values, then you need to use methods.
Our classes are made with properties and methods.
Suppose I create a class named calculation.
Then I create some variable as properties.
We declare these three variable within this class, and if you want to assign values to these properties,
you need methods.
Methods are basically functions.
Suppose we want to add numbers.
So I'm going to create a function named sum.
And as you can see we perform some calculation in this function.
First we take a variable name c and then add two variables a and b and we return c.
We can use only those property in our method, which we already declared in our class, and we cannot
use properties which is defined in outside the classes.
Here you can see we just create one method in our class, but you can create multiple methods in this
class at the same way.
I'm going to create another method name sub sub mean subtraction.
So let me show you the syntax how we can declare class.
And also I'm going to show you how we can create property and methods.
Suppose I'm going to create a class name.
Hello.
So at first we need to type class keyword.
Then our class name which is hello.
Then inside the curly braces.
Here we need to create properties and method inside this class.
Suppose I want to create a method named methods for that.
First we need to take the method name in our case masses.
It's a normal function just here we don't need.
To use function keyword before the function name.
At the same way, for parameters, we need to use parenthesis.
Then inside the curly braces we can define our masses.
In our case I want to print.
Hello everyone in our console.
Now masses become a method.
You can create multiple methods in a class and if you want to call this method first you need to create
an object using this class.
So first we need to take a variable in our case A and assign this class.
Also to assign this class we need to use new keyword.
Then our class name.
This will turn our variable into an object.
After creating this object, we can access all the properties and methods from this class.
Suppose I want to call masses method.
Then first we need to type the object name in our case a dot.
Our method name message.
And if you want to send any argument then you can do.
Usually we need to do it for function.
So this is it for this tutorial.
In the next tutorial we are going to learn about practical.
So thanks for watching this video.
Stay tuned for the next tutorial.