1. Intro to Objects

intro-to-objects

What are Objects?

You are already familiar with JavaScript objects, but let's review. Recall from previous lessons that the object is one of 7 types in JavaScript.

Most all languages have some kind of implementation of a key/value pair data structure (what an object in JavaScript seems to look like). For example:

  • Python's Dictionary
car = { 'color': "red", 'wheels': 4 }
  • Ruby's Hash
car = { "color" => "red", "wheels" => 6 }

As we've already seen, if we were to diagram a JavaScript object (how it looks in memory), it might look something like this:

var car = { color: "red", wheels: 4 }

object diagram

In JavaScript, like most languages, Objects have more functionality than just acting like a key/value store. They also have methods and properties that come for "free" with the Object prototype. You've seen some of these with the .length property, but we'll cover the Object prototype more in depth later.

Complete and Continue