What is an object? Anyway. This is an essential concept in JavaScript. We really need to get to grips with this question and understand what an object is. This is the essence of object oriented programming, which is found in lots of language is not just JavaScript. So an object is a collection of data values that are somehow grouped together into a compound value. The data is organized with sets of properties and their corresponding values to have pairs of property value, property value. And really this collection of data describes an entity, an object. Recall. When we started off on our computational thinking journey, we had this picture of the landscape. A is the application area. This is the real world which has a problem that we want to solve using computer programming. B is the building blocks domain. These are the concepts and mechanisms that we can employ in our computer programs. And then C is what we do. That's computational thinking which is somehow solving the real world problems by modeling their important aspects using the computational mechanisms. Now, this is crucial, objects provide us with a natural bridge from A, application area to B, building blocks. Objects allow us to model real world entities directly, things with properties that have values. So objects are very useful in this domain. Let's look at how we represent objects now in the syntax of JavaScript. The syntax is the nuts and bolts of the language. The actual characters that we have to type onto our keyboards in order to get the JavaScript code to work properly. So we'll go through the declaration and definition of a simple object here. And we notice first of all we used the var keyword for a variable, you could use let as well I suppose and then we give the object a name. So I'm calling it myObject but this could be any variable name. We like really, any legal variable name in JavaScript, I've called it myObject and then we have an assignment. So we're setting myObject to be some particular object value. And notice the use of these curly brackets here, curly braces. Everything that belongs to the object is going to be put inside these curly braces. This encloses the object definition. Look, here is the property value pair. The property is on the left hand side. It's called flavor. The value is on the right hand side, it's a string value and it's choc, I think that's short for chocolate there. Okay, notice the punctuation. The property is terminated with a colon and the value is terminated with a comma and we can have lists of properties and values. Look here's another property, price and its value is a floating point number, a decimal number nor 0.99 which presumably represents how much it costs to buy this chocolate flavored object. And again we've got the colon to separate the property name from the property value and the comma at the end of the line. So this is a simple object declaration. This object has two properties. The properties have to be strings but we don't put them in a double quote. And then the values can be of any type. And you see here we've got a string value and a floating point value. That's myObject. Ooh, now let's think about how to extract the values from the properties in my object. And the same as with a raise. You know when you have an array, you use the square bracket notation and the integer index to fetch a single element out of the array. Well, it's the same with objects. You can use square brackets and specified this time as a string. The property name and that will return the value. However, an alternative equivalent. And to be honest, more popular way of fetching the value is to use the dot notation. So you put down the name of the object and then a dot and then the property name without the string quotes here. myObject.flavour. And that will give you back the value that's associated with the flavour property in the myObject object. There we go. Let's look at some example JavaScript code. Now, to see this. Working in action. We'll start with the first object called spider. Look here's the legs property which is an integer and the tail property which is a Boolean. Let's Inspect the legs property of spidies. And the square brackets notation to eight. Let's use the dot notation. Now spider dot legs. Again, the spider has eight legs. Now we're going to try and print out the spider itself on the console and we just see it's an object. Let's make another object. Now this is a sheep which has four legs and a tail under snake, which has no legs, but it does have a tail. So all these objects have common properties, legs, integer tail Boolean. Now we're going to create a draw it function which is going to have a string variable. The O represents the head. And then we're going to iterate over the number of legs. Animal dot legs, animals named the parameter. And then for each leg we're going to a pendant I character onto our string. Finally we're going to look at the tail property of the animal. If it's true, we're going to a penda hyphen character onto our string. At the end of the function, we will print out the string using console dot log. So let's call this, draw it function with the spider object and we see ahead and eight legs, we did. Again, the sheep object ahead four legs and a tail. And finally the snake object just ahead of the tail. Let's just quickly summarize what we've learned about objects. First of all, we now know the objects are compound values, their collections of data in JavaScript that are grouped together. Objects consist of sets of property value pairs where the properties are strings and the values can be of any data type objects can provide us with a way of modeling real world entities. And this allows us to bridge from the application area through to the building blocks that we use to construct our JavaScript programs. We've seen things a bit like objects before. You think about records in a database perhaps, or Rose in a CSV file. Each record or each row describes a real world entity capturing some of its data and objects do this as well. Only their variables in our JavaScript programs. More about objects next time. Thanks. Bye.