The Object-ive

[Week 1 - TAAQUI GIPHY] · Lesson 3 · 10 minutes

We continue our overview of basic javascript terminology with all things objects.

To make our functions, as well as the rest of our code, work, javascript has to know what it's dealing with. It has to know the variables, the names and values of the data we're asking it to use. So for instance - 


We've just declared three variables - one is a string, or a series of characters. One is a number. And one is a boolean, or a true/false statement. 

But javascript also supports variables called objectsJust like any object in the real world, which will have height, width, color, and weight, objects in javascript contain multiple properties. They can contain all kinds of variables, even other objects and functions. So in the following case: 


.fullName is a string property of the object TaqKarim, with a string value of "Mottaqui Karim." 

In a more complex example, you can take advantage of certain properties of an object in order to create a function: 


If you don't already know what it does, the console.log is going to be a trusty companion throughout this course and your coding life. It's function that logs, or records, the results of a function or the different values we're passing into that parenthesis on the console, which you can access by right clicking on a Chrome browser page and selecting inspect. 

This type of function, a function which is also the property of an object the way .log is a property of the object 'console,' can be called a method

You can also write a function so that it returns the whole of an object. Like so: 


What this illustrates is our original four lines of code. Document is an object, with a function called querySelector, which runs with the the parameter .jsgo we passed in; and another function, .addEventListener, works in reaction to that, with the arguments click and onGoBtnClicked, which we've defined. 

Ask A Question

Having trouble? Don't worry, you're probably not the only one. Check out the questions other students have or ask yours.