Are you ready for some object oriented programming, short up, JavaScript up, so objects are used
to model and organize and group content together, so similar items, similar tasks in what's known
as a class, and this provides a whole lot more flexibility and it's also easier to extend upon.
So you can think of a class as a blueprint or template definition of objects, properties and how it's
all held together.
In order to use classes, we can construct the object and this makes it easier to do it over and over
again using the blueprint as a guide in order to make those constructions.
So we urgently saw how we use the literal notation and we create an object.
And this time we're going to create the object.
But we're going to use a constructor notation and I'll show you how that works.
So first of all, creating the function and we'll call this one blue print.
You notice with classes, typically we started with uppercase character.
So that indicates that this function is going to be used as a constructor.
And then here we can add in information so this stuff can be equal to yes, this Greece can be equal
to hello.
And now we can use that to create objects.
So we've got our first objects so we can create object number one.
And using the blueprint, we do new blueprint and that's going to construct that information within
the object one.
And the nice thing about it is if we can if we want to create another object with the same blueprint,
that's really easy to do.
So let's try this and we'll see my object.
One has stuff has Grete.
So if we do my object one and if we do stuff you can see, yes, returned and greet is returned.
If we do greet so we get hello being returned back.
So they work the same way as what we saw with the other objects when we were creating it through the
literal notation.
But this is just another way to create objects.
And the way that you use and which one you choose is up to you depending on what you're doing within
your coding.
But with this format, it makes it a whole lot more flexible.
So think of this always as a blueprint in order to create objects and that you can really easily reuse
and make adjustments within the blueprint to construct the object differently and add more functionality
into the object.
So go ahead and try this out, creating a function that you can use as a blueprint and then create a
few objects using that.
And don't forget the new in order to indicate that you're using and creating a new object, using the
function to try to.