Skip to content

Instantly share code, notes, and snippets.

@rogerwschmidt
Last active May 5, 2017 03:03
Show Gist options
  • Save rogerwschmidt/32efb0340b6f3796dec51dd2f3ba60d8 to your computer and use it in GitHub Desktop.
Save rogerwschmidt/32efb0340b6f3796dec51dd2f3ba60d8 to your computer and use it in GitHub Desktop.

Objects

Objectives

Describe the differences between objects and arrays.

With your neighbor, discuss the differences between objects and arrays.

Create objects using the object literal syntax.

Create an object literal that contains the following keys, and appropriate values:
- firstName
- lastName
- age

Store the object in a variable name person.

Access and add values in an object using both bracket and dot notation. Describe the difference between them.

Add the following keys to the object created in the previous CFU
- favoriteCity
- favoriteIceCreamFlavor

Use both, bracket and dot notation to print out favoriteCity and favoriteIceCreamFlavor

With your neighbor, discuss the diferences between bracket and dot notation.

Strech goal:
Use a Object.keys() and a for loop to print out all of the key-value pairs

Combine objects and arrays to create arrays of objects and objects with array values.

Create an object that contains the following keys, with appropriate values:
- favoriteIceCreams
- favoriteCities

In each key, store an array with appropriate values. 

Combine targeting methods to target specific values in objects which are in an array.

Given the following array:

var superheroes = [
  {
    heroName: 'Superman',
    civilianName: 'Clark Kent'
  },
  {
    heroName: 'Batman',
    civilianName: 'Bruce Wayne'
  },
  {
    heroName: 'Green Lantern',
    civilianName: 'Hal Jordan'
  }
]


console.log() Batman's civilian name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment