Before I tell you the objective for this video, let me ask you this question.
Let's say that I'm the owner of my company.
And then you are the employee.
Right.
And then I ask you that now we have this person details here.
I can ask you that, please.
Go to the person's record and then just print me out the name only of the person.
How am I going to do it?
And this is what you call accessing object properties.
Perfect.
So this section is all about accessing object properties.
And how can we do that?
So.
So accessing object properties simply means that pulling out the values you need from from an object.
And that is all getting the properties you want from an object is called the accessing property names.
So come down here.
Nice command as accessing.
Property objects.
Object properties?
Yeah.
Object properties.
Yes.
Good.
So we have two ways of doing this.
So let me bring this one here.
Let me comment out.
And now let me bring it up, because this is a new concept.
Okay.
So how can we access properties of an object the same way?
We have two ways.
One is using the dot notation.
Using the dot.
Notation.
Yes.
So here we go.
I would say, okay, get the name of the person.
So here we go.
So I take the person object which represents the who of my object here.
Then I'll make use of dots and see that I have my property indicates that the the symbols here is different
from this one.
You see that this tells you that there's a property on my object.
And if you read here, it says, what is property?
And then the variable name is what is married.
The first one and the value is a boolean.
Okay, we see if I move my mouse on the edge, you can see that I have a property and it's a number.
If you see my cursor here.
Yes.
You see that?
If I open it, I have the more details about that, then that is how it is.
So let me see.
I won't have the person's name, so I'll type name and now I get a name so I can assign the variable.
The result a variable called person.
Let me say a person name.
P name is equal to that.
So if I insert that log the person name which is P name, person, name.
You see, I have John.
Perfect.
So how can we access person h using the dot notation?
So the same way make use of the H.
So let me say bring this one here.
Down here.
Let's say get there, get the name h of the person this h of the person so person p name p h.
Well the name must be disclosed.
The person name to be more precise.
Otherwise is not descriptive.
P name is what?
Sorry guys.
My naming is not good person.
Name.
Yeah.
And then person.
H like that.
Good.
So now if I check for person H here inside mine, I have the person h if I check for a person.
Person.
H h is what?
Yeah.
Sorry.
H is h sorry.
Sorry guys.
So person H I have 30.
Then let's also check.
Get the person.
Mary Stiles, let me say stutters.
But.
Starters like that.
So I can also check for the person status here.
Person status?
Hey.
I was.
So it's married?
Yeah.
So if I check for.
What am I doing?
So here is a different thing.
So let me copy this one.
And here you're going to be the person age.
No.
What am I doing?
Sorry, guys.
So let's say it is a person status.
Get.
Get the person.
For starters.
Get the person of the.
Get a person.
Married.
Starters.
Okay.
Sorry for that, guys.
So we see that if I stay, for starters, I'm going to get three or four.
So, again, person starters.
Now it is true because here is true.
So what about if I want to get the person?
Hubby, get the.
Person hobby.
Tavis So here you're going to be person.
Hobbies.
Now it's here.
As what?
Hobbies?
Is that so?
If I check for person hubby's here.
I have it.
That is the first method using the dot notation.
So here we have some beautiful comments here to tell you that it's a sub topic.
The next one is copy this.
One is using the bracket notation, using the bracket notation and it's here you go.
So here, let's say let me bring up this one here again.
Bring this one.
Let me show you first before I mess up with the code here.
So I would take my person object and then scrape brackets and here code and see that I have the property
name as before.
I can say h.
Now I can assign this one to a variable called person H.
So it comes as person.
Each is equal because I have the variable here.
Let me comment this one out.
And now if I check for person h.
Person h.
You see, I still have theory.
It's also a way of what?
Accessing the properties of an object.
So the same thing.
We can go ahead and also get a person happy.
So here is the person hobby.
Let me comment this one out.
And here I'm going to use the square bracket.
Like this single code or double code.
Any of this one will to be fine.
So if I check for person hobby, I still have it.
What is it about the bracket notation?
The next video.
Let's see how we can update object properties.
Let's say that.
This is a record you have about a user.
And then after two months or one year, the user sees the place.
I have changed my name, so go ahead and update my name.
And this mostly used in application, for example, updating a user record this where all of this logic
comes into play.
So objects made this one happen to be able to quote update a record in our database.
If you're familiar with MongoDB, you call it as fine by ID and update by.
We can do it using JavaScript, using the updating logic or concept to be able to update a data in an
object.
So in this video, let me show you how we can update record in an object.