Introduction:

Objects are perhaps the most important things in any code language, as they model the real world.

In JavaScript, their data is stored in key / data pairs:

Much like [arrays], they are created by declaring a vairable and assigning it with key / data values. However, these pairs are stored in {} brackets. The key is the left hand argument, while the data is the right hand side. Objects can store can hold data, methods, properties, functions and more. Above, we used simple data like car mosdel. Let's now make an object containing a function, and then call it:

Notice that firstly, we have to call the object.key function like so:

dogsdamour.bio()

We cannot call simply bio();.

In our previous lesson on functions, we learned about function expressions. This is a good example of one.

The key value "bio" in this case is operating as the function's name variable. We could define it like so:

JavaScript has reserved words, but these can be used as keys.

Also notice that we have used this.key to call the keys' data values. We shall talk more about this soon.

Here, when we click the button below, we will see the results.