Welcome to dyslexia in dyslexia will learn about important concept in the javascript which is object
which is another important data types of javascript.
So we have learned about the numbers string and integer even and now it's time to talk about the object
so object is anything that you see in the real life so it can be the animal it can be thing.
So we have take the small example over here which is the bike.
So in real life a bike is an object.
So what you can see in the bike and what this bike does is all about the properties and method of that
object.
So we have taken this small example of the bike.
You can also see the car.
You can also take any animal which have their own properties and the methods so properties is the attribute
of that object.
So in this case bike will have the name it can have the model it can have the weight and the color so
you can see it can be different from each of the properties of the object.
We can take another bike which have the different name it can have the different color it can have the
different weight but if you see the methods which is the behavior of the object that means the two motor
bike can start and they can also drive.
They can also break and they stop.
That means that they will do same method or they are responsible for invoking the different method at
a different time but they have the different property to different object will have the different name.
They will have the different model different weight in the color but in the case of the method or the
behavior they can start gray brick.
You stop at the different time.
That means any object will have the properties and methods.
They will have the different properties but they will be certainly doing the same methods are the behavior
at the different time.
So you can see over here all bikes have the same properties but the property's value differ from bike
to bag.
That means they will have the name model weight color but their values will be different from bike to
bike and all bike have the same method.
That means they will do is start drive.
Break is stop but they will perform that method at a different time.
One bike can perform the drive and other can perform my stop but they will just perform this method
that is all the same meters from bike to bike and the property's value will be different for different
object.
You can also take the example of the enemas and you can be taking the example of let me see the batters.
So better to have the name.
So one battered can have the different name and another have the different and it can have a different
colour.
It can have different weight and it will do the same method so they can just sleep they can the stock.
So this method will be the same for the different objects but the property's value will be different
from optics to objects.
So listed small example over here so I have just opened my Sublime Text so if you see we have a simple
as demo layout over here which is just a header but here which is basically a heading title which is
is to obey a paragraph having the demo will just make a script which is zapped by script and it will
just create the object over here and display some data from that object.
So first of all when there is a set on these document you will see will have only the javascript object
which is the header over here.
So let's create the script now.
So first of all I want to create the object so object will be created by the same via cured like we
just used to create the variable which can be number which can be strings.
So we'll just create the object with the same body cured and as a sick God or you can also a bike because
we are just taking the example of the bike over here.
So just say bike so I'll just create object with these Kali braces.
So this is the way to create the in the object.
So if I just print this now then you will see empty object will be created.
But I want to give some properties to this bike so I'll just sit tight because we have talked about
the type of the model.
So I'll just say this type will be spooky and I'll just say that the next attribute will be the model.
So model would be let me say three hundred sixty bike and the next one would it be the colour.
So colour is another attribute and I want to give the colour as is black.
So this is our object in this case we have a bike object which will be created with the same var cure
and this scholarly basis inside this we give these attributes and the value to this attribute will be
assigned by this column.
You can't do something like equal to to assign here you have to make use of the column to assign the
values to the attribute.
So these are the attribute.
Now let's make use of some away to this display the data from this bike.
So let me just say first of all document dot get the element because this is the way to get the element
because we have already started about the DOM which is basically the way to manipulate the element of
this demo.
So we want to do something like We want to since this paragraph all for demo to add the element of the
bike.
So let me say over here that is these is paragraph first so I want to change this content of this is
paragraph to the VAR which is basically the object on the da da da da da object.
So first of all I want to get that element which is demo because we want to just grab this paragraph
and now I want to Jane's that this element which is the way to do with this inner is dismal.
So I want to add scenes to something.
Let me give this string first and I see the car or the bike the bike type is and I want to this concatenate
that means I want to add with these plus sign and give the car or bike.
Sorry.
Here is the bike so I want to use this bike.
And if you want to just make use of any of the attribute of this bike you have to first give the PDA
and after that you have to make use of these type which is that tribute of that object.
So let me just quickly go over here and let me first run these console and soil what I'll just do over
here.
So let me just quickly clear this small variable object.
Let me see person is my object and I want to create this person name and I want to give this system
my name and I want to this give roll and it would be twenty three it's an order which is the barometer
and I want to give 30 four okay.
Now I've created the person variable which is the object and now if you want to just assess this the
role of this person you have to do something like person give the period and you can just make use of
let me say a roll then you could see twenty three over here.
You'll just assess the value of this object by giving the period and the type or basically the attribute
of that object.
If you want to do the another way you can also do something like this.
You can pass your role and if you do this you'll just get the same answer over here which is the twenty
three.
It is then another way to assess the object which is to attribute the properties so you can do something
like person.
And you can see something like AIDS which is AIDS over here and it will get thirty four here.
So this the way to assess the object attribute.
So we'll just do that over here which is in our Sublime Text.
So what we did was we just get this object which is the bike object and I want to get the value of this
attribute is a type.
So I'm just doing DOT and the type over here.
So that means it will just return something that is the bike type piece and the subject you will here
in studio.
This is paragraph.
So let's take this first to go to our much lower here.
Let me rephrase this.
Then you have this is the paragraph so something is happening over here so as to see that this yellow
is a smaller over him.
So let me say this.
Go back and you'll see the bike type is Suzuki.
So we have created our own object which is bike object.
We assigned the attribute to this bike and we just jeans here with the help of this DOM manipulation
and we make use of this paragraph is the text to see this string over here saying the bike type reason
we just this is the object attribute over here with this dot operator you can also say something like
model and you'll see in this bike model too.
So I'll just say that phrase again in the model is 360.
So bike is 360 if you want to just make something like bike galleries music galleries and Alice concatenate
this with the first bike.
And it should be color and up to that.
I want to give again.
Okay.
Something is happening over here because I have to give him a column first and it is good to go.
So let me just remove this species from here
so it was good.
So let me save this town and let me just go back in.
Is this okay.
Nothing is happening because I have made the collar which is the bike girl over here and after that
you have to again concatenated with this model.
So let me save this down and again run this and you'll see the bike all is black and the model is 300
CCU so you can assess the variable that is the object attribute to these ways.
So this will be read for dyslexia we learned about the objects in this lecture how to create them how
to assist them and you can also make a fun sense inside this variable which is the object you can assist
that funds and it can be anonymous once an not it can be any funds and that is the method of this object
and you can assess like this you can just make some method inside here and it will this is is the same
way that we just DDA but in steering this put the argument or basically any parenthesis and empty if
you this created the method with in the just declaration it will just pass in empty parenthesis over
here and this the way to this assist the method of the object if you create any of the method inside
these objects so this will be there for these selected soon the next one.