Introduction

VIDeO

Properties and Methods

We've been using properties and methods all up to this point, and in the next section you'll bring your knowledge of object-oriented programming to another level of sophistication by creating classes(i.e.,categories) of objects!

Since an object can represent data _and _functionality, we can use an object to express real-life things (i.e., someone or something) in code. You've seen a few one-off examples throughout the course, but now let's take a deeper dive into it!

VIDEO

Reflect

Find something around you and create an object of its properties and methods.

SUBMIT

VIDEO

Now it's your turn! Take some time to look around your area for objects and reflect on ways that they can be grouped. For example, perhaps a tumbler and a mug each belong to aCupclass. Or, maybe a corgi belongs aDogclass, and asunflowerbelongs to aFlowerclass.

  • [x] Task List: I have reflected on nearby objects and ways that they can be grouped.

Object-Oriented Programming

To recap the above, objects in JavaScript can represent real-life things. That is, objects can have properties to represent attributes _or _characteristics, as well as methods to represent actions _that can be performed. Using the analogy of spoken language, you can think of objects as _nouns, such as a "dog" or a "car." Values of properties are adjectives, such as "blue." Methods, then, are the verbs, such as "bark" or "drive."

In the next section, we'll take a dive into object-oriented JavaScript, beginning with constructor functions. If you've had experience with object-oriented programming in other languages (e.g., Ruby, Python, etc.), you may be surprised to learn that JavaScript does not have a traditional class system (namely, one where the compiler does a lot of organizing out of sight). Instead, the class system is built directly using functions and objects. So rather than using a special class syntax, in JavaScript we define constructor functions. Let's dive right in!

results matching ""

    No results matching ""