1
00:00:00,570 --> 00:00:03,570
This section is all about.

2
00:00:04,310 --> 00:00:07,070
JavaScript object.

3
00:00:07,550 --> 00:00:14,390
Well, if you have been following me from the beginning of this section of JavaScript up to this point,

4
00:00:14,390 --> 00:00:17,870
and you've tried my hands on some of the coding challenges.

5
00:00:18,140 --> 00:00:24,650
So after this section, you can regard yourself as no more a beginner in JavaScript.

6
00:00:24,680 --> 00:00:30,260
Well, that is why JavaScript is an object oriented programming language.

7
00:00:30,470 --> 00:00:32,509
So what is an object?

8
00:00:32,689 --> 00:00:41,330
Well, looking at this picture over here, we see that we have different entities a card, a dog tree

9
00:00:41,450 --> 00:00:43,550
person, and a book.

10
00:00:43,640 --> 00:00:50,210
So all of these entities are regarded as a or as an object.

11
00:00:50,570 --> 00:00:58,790
So objects in JavaScript are variables that hold multiple pieces of information.

12
00:00:59,570 --> 00:01:01,970
So let me prove you something here.

13
00:01:03,220 --> 00:01:08,800
At first we talk about, I mean, how we can declare a variable, right?

14
00:01:08,800 --> 00:01:13,300
That's variable declaration, meaning how we can store data into a variable.

15
00:01:13,330 --> 00:01:14,860
That's the first point.

16
00:01:14,980 --> 00:01:23,830
So let's take it that we have this person over here, this person over here, and this person.

17
00:01:23,830 --> 00:01:26,980
We want to save some details about this person.

18
00:01:27,040 --> 00:01:33,520
Well, in the first place, we can use the variable declaration, how we can declare variables that

19
00:01:33,520 --> 00:01:35,530
I want to keep track or the person's name.

20
00:01:36,850 --> 00:01:38,050
The Age.

21
00:01:39,250 --> 00:01:41,550
And let's say the person city.

22
00:01:41,560 --> 00:01:42,900
Let's say the person city.

23
00:01:42,910 --> 00:01:43,570
Yes.

24
00:01:43,660 --> 00:01:49,990
So for this one, we can save this person details in a variable by declaring variable.

25
00:01:49,990 --> 00:01:52,780
I say let's say let or cause.

26
00:01:54,250 --> 00:01:59,320
Person name is equal to John.

27
00:02:00,490 --> 00:02:04,810
You can say the same cons comparisons, let's say age.

28
00:02:05,540 --> 00:02:08,330
Is equal to three like that.

29
00:02:08,360 --> 00:02:09,740
So this is okay.

30
00:02:09,740 --> 00:02:14,630
But what about if we have a lot of properties here, let's say 20 properties of this person?

31
00:02:14,660 --> 00:02:16,640
Are we going to declare all these?

32
00:02:17,570 --> 00:02:18,740
Let, let, let, let, let.

33
00:02:18,740 --> 00:02:19,640
Like that one.

34
00:02:19,820 --> 00:02:20,510
No.

35
00:02:21,140 --> 00:02:23,770
So this one is an ideal way to go.

36
00:02:23,780 --> 00:02:27,010
Then we went ahead and talk about arrays.

37
00:02:27,020 --> 00:02:27,800
So.

38
00:02:27,800 --> 00:02:30,170
So we can say that we have cost.

39
00:02:31,360 --> 00:02:32,340
Person.

40
00:02:32,920 --> 00:02:35,230
I re now for this one.

41
00:02:35,260 --> 00:02:37,690
See that we can save all these details.

42
00:02:37,710 --> 00:02:39,550
Let's say the person name is John.

43
00:02:40,550 --> 00:02:43,850
Age is 30 and the city is New York.

44
00:02:44,480 --> 00:02:47,230
You can see that there is some improvement, right?

45
00:02:47,240 --> 00:02:50,150
Because here we have reduced the number of codes.

46
00:02:50,390 --> 00:02:55,310
So if I refer to persons as Ray, I'm getting all the details inside here.

47
00:02:55,490 --> 00:02:58,730
But guys, there is one problem also here.

48
00:02:59,330 --> 00:03:07,200
Let's say that after ten years and you take this person away because of this person pay, then I is

49
00:03:07,220 --> 00:03:07,700
a person.

50
00:03:07,700 --> 00:03:11,000
Then I see John, I see 30, I see New York.

51
00:03:11,480 --> 00:03:15,530
So these variables here are not all that descriptive, right?

52
00:03:15,680 --> 00:03:19,520
So this name can be John can be a name of a book.

53
00:03:20,120 --> 00:03:23,420
So how will I know that this is a name of a person?

54
00:03:23,840 --> 00:03:25,550
What about this 20?

55
00:03:25,580 --> 00:03:29,360
It can be amounts of money I have in my pocket.

56
00:03:29,480 --> 00:03:34,940
Or is the number of quantities of, let's say, a product where.

57
00:03:34,940 --> 00:03:35,580
I don't know.

58
00:03:35,600 --> 00:03:36,880
So what about New York?

59
00:03:36,890 --> 00:03:38,180
Is New York here?

60
00:03:38,180 --> 00:03:38,690
Name of.

61
00:03:38,690 --> 00:03:38,980
I don't know.

62
00:03:39,020 --> 00:03:39,720
We see that.

63
00:03:39,740 --> 00:03:44,990
Well, that's why we need a way, a proper way of storing data.

64
00:03:45,410 --> 00:03:46,030
Right.

65
00:03:46,040 --> 00:03:48,920
That is why Object comes into play.

66
00:03:49,250 --> 00:03:56,660
So with Object, we can give a key value per a value and a property which is more descriptive.

67
00:03:56,870 --> 00:04:04,970
That is why it is that objects are used to hold multiple pieces of information and we can create objects

68
00:04:04,970 --> 00:04:06,710
using this carry basis.

69
00:04:07,100 --> 00:04:12,020
So let's see in details, more details about what object is or about.

70
00:04:12,740 --> 00:04:15,500
So in what case, let's take that.

71
00:04:15,500 --> 00:04:17,149
You want to keep track?

72
00:04:17,390 --> 00:04:21,829
I mean I mean, save detailed information about this person, right?

73
00:04:21,829 --> 00:04:28,280
So this person can have a name, have a person have said the person has an eye, the color of an eye,

74
00:04:28,280 --> 00:04:29,270
an arm.

75
00:04:29,270 --> 00:04:31,550
They see the shoes, the color, everything.

76
00:04:31,550 --> 00:04:33,320
You want to save it in an object.

77
00:04:33,320 --> 00:04:34,310
So let's see.

78
00:04:35,030 --> 00:04:35,540
Good.

79
00:04:35,720 --> 00:04:40,490
And objects are created using this carry braces.

80
00:04:41,560 --> 00:04:44,170
So let's see in more details about that.

81
00:04:44,200 --> 00:04:44,920
Perfect.

82
00:04:45,340 --> 00:04:52,450
So with object, we have control over the property of our particular object that we are dealing with.

83
00:04:53,050 --> 00:04:59,620
So let's say that in application, you want to keep track of this particular object before I come into

84
00:04:59,620 --> 00:05:07,450
this one in the application out there, they are all made up of object creation.

85
00:05:07,810 --> 00:05:13,260
So let's say that we have a block application for block application.

86
00:05:13,270 --> 00:05:19,380
We need an object to be able to create a block and the same object.

87
00:05:19,390 --> 00:05:21,220
We can delete a block.

88
00:05:22,370 --> 00:05:23,640
At the same time too.

89
00:05:23,640 --> 00:05:24,940
We have users, right?

90
00:05:24,960 --> 00:05:27,750
We can create users from an object.

91
00:05:27,780 --> 00:05:29,970
That's why objects are everywhere.

92
00:05:30,330 --> 00:05:35,460
So here we have the object name first and it is called a person.

93
00:05:36,220 --> 00:05:42,430
And this object has properties, the name H and many more.

94
00:05:42,850 --> 00:05:50,720
So the properties are, for example, the name the H, the the person's colour, the person's country.

95
00:05:50,740 --> 00:05:52,780
These are the properties of the person.

96
00:05:52,900 --> 00:05:55,660
Then we give it a value as that.

97
00:05:55,750 --> 00:05:59,220
We come back to how we can assess our properties.

98
00:05:59,320 --> 00:06:02,260
For the meantime, these two methods are equal.

99
00:06:02,530 --> 00:06:04,480
And this one is also equal.

100
00:06:04,900 --> 00:06:12,010
And one good thing about object is that we can add our custom methods.

101
00:06:12,940 --> 00:06:13,340
Right.

102
00:06:13,360 --> 00:06:21,820
So under arrays and strings, we only use the default method given to us by JavaScript.

103
00:06:22,060 --> 00:06:31,810
So arrays we have a method, for example, push pop shift last index of and many more and string tool.

104
00:06:31,840 --> 00:06:39,100
We have a method like splits and then to lowercase to uppercase and for objects.

105
00:06:39,220 --> 00:06:43,180
Well, we have some methods by default method.

106
00:06:43,360 --> 00:06:51,100
But the good thing is that we have the flexibility to add our own method how awesome it is.

107
00:06:51,460 --> 00:06:55,180
That's why object is really crucial.

108
00:06:55,420 --> 00:07:03,910
So we can add our own method to object and you view customize it the way we want it to be.

109
00:07:04,390 --> 00:07:07,070
Unlike array method, for example, let's say live.

110
00:07:07,700 --> 00:07:15,140
If you slam, we cannot customize because a built in it only retains how many elements in a particular

111
00:07:15,140 --> 00:07:15,710
array.

112
00:07:15,800 --> 00:07:23,870
Above object we have more flexibility now that you go the overview of an object than this video.

113
00:07:24,200 --> 00:07:27,950
Let's see how we are going to create object from scratch.

