Transcript of the tutorial.
TOP
All right then, gang.
So you've made it this far without getting bored.
Kudos.
And now I'd like to turn our attention to objects in JavaScript because objects are a huge part of the
JavaScript language and they are at the core of many things we do.
So learning how to use them is going to be essential.
Now the best way to understand what an object in JavaScript is is to compare it with a real life object.
So objects in real life, they have properties and they have things they can do, right?
So for example, a phone is a real object and it has properties.
It could have a color, a size, a model, etcetera, but it also has things it can do.
It can ring, take a picture and play music.
Now, an object in JavaScript is no different.
It has properties and it can have things it can do.
So for example, we could have a user object in JavaScript and those properties would be an email,
a username and a gender.
And it also has things it can do.
But in JavaScript these are called methods which remember are just functions.
So for example, a user object might have these methods, a login method and a log out method.
Another example would be if we had a blog object which represented a single blog on a website.
Now the properties of a blog object could be the title, the content and the author, and the methods
could be a publish method, an unpublished method, or a method to delete the block so you can see how
real life objects and JavaScript objects are quite similar.
They both have properties and they both have things they can do, but in JavaScript they're called methods
which are functions.
So this idea of objects is going to allow us to create these kinds of data structures which represent
certain things in our code or web applications.
So JavaScript has some built in objects to the language which we will use as well, such as a date object
and a math object.
And we'll see those as we go forward.
But it also allows us to create our own objects.
We can do this in a variety of different ways, and this section will be focusing on how to create individual
objects using what's known as object literal notation.
Now, that sounds way more complex than it is, and we'll see exactly how simple it is to create objects
this way in the next video.