1
00:00:00,420 --> 00:00:08,760
Are you ready for some object oriented programming, short up, JavaScript up, so objects are used

2
00:00:08,760 --> 00:00:15,330
to model and organize and group content together, so similar items, similar tasks in what's known

3
00:00:15,330 --> 00:00:21,840
as a class, and this provides a whole lot more flexibility and it's also easier to extend upon.

4
00:00:22,080 --> 00:00:29,250
So you can think of a class as a blueprint or template definition of objects, properties and how it's

5
00:00:29,250 --> 00:00:30,720
all held together.

6
00:00:30,930 --> 00:00:37,680
In order to use classes, we can construct the object and this makes it easier to do it over and over

7
00:00:37,680 --> 00:00:42,470
again using the blueprint as a guide in order to make those constructions.

8
00:00:42,480 --> 00:00:47,430
So we urgently saw how we use the literal notation and we create an object.

9
00:00:47,430 --> 00:00:49,440
And this time we're going to create the object.

10
00:00:49,440 --> 00:00:52,800
But we're going to use a constructor notation and I'll show you how that works.

11
00:00:53,010 --> 00:00:57,500
So first of all, creating the function and we'll call this one blue print.

12
00:00:57,610 --> 00:01:02,880
You notice with classes, typically we started with uppercase character.

13
00:01:03,060 --> 00:01:07,200
So that indicates that this function is going to be used as a constructor.

14
00:01:07,200 --> 00:01:16,260
And then here we can add in information so this stuff can be equal to yes, this Greece can be equal

15
00:01:16,260 --> 00:01:17,520
to hello.

16
00:01:17,520 --> 00:01:20,600
And now we can use that to create objects.

17
00:01:21,210 --> 00:01:25,650
So we've got our first objects so we can create object number one.

18
00:01:25,920 --> 00:01:33,300
And using the blueprint, we do new blueprint and that's going to construct that information within

19
00:01:33,300 --> 00:01:34,440
the object one.

20
00:01:35,010 --> 00:01:40,350
And the nice thing about it is if we can if we want to create another object with the same blueprint,

21
00:01:40,680 --> 00:01:41,790
that's really easy to do.

22
00:01:42,040 --> 00:01:44,490
So let's try this and we'll see my object.

23
00:01:44,490 --> 00:01:47,040
One has stuff has Grete.

24
00:01:47,430 --> 00:01:54,440
So if we do my object one and if we do stuff you can see, yes, returned and greet is returned.

25
00:01:54,450 --> 00:01:57,530
If we do greet so we get hello being returned back.

26
00:01:57,720 --> 00:02:02,850
So they work the same way as what we saw with the other objects when we were creating it through the

27
00:02:02,850 --> 00:02:03,810
literal notation.

28
00:02:04,050 --> 00:02:06,300
But this is just another way to create objects.

29
00:02:06,600 --> 00:02:11,460
And the way that you use and which one you choose is up to you depending on what you're doing within

30
00:02:11,460 --> 00:02:12,150
your coding.

31
00:02:12,180 --> 00:02:15,270
But with this format, it makes it a whole lot more flexible.

32
00:02:15,420 --> 00:02:22,200
So think of this always as a blueprint in order to create objects and that you can really easily reuse

33
00:02:22,350 --> 00:02:28,380
and make adjustments within the blueprint to construct the object differently and add more functionality

34
00:02:28,380 --> 00:02:29,150
into the object.

35
00:02:29,490 --> 00:02:35,820
So go ahead and try this out, creating a function that you can use as a blueprint and then create a

36
00:02:35,820 --> 00:02:37,890
few objects using that.

37
00:02:37,890 --> 00:02:43,770
And don't forget the new in order to indicate that you're using and creating a new object, using the

38
00:02:43,770 --> 00:02:45,390
function to try to.
