- Create and manipulate arrays and objects
- Explain the difference between object dot notation and bracket notation
- Explain how objects are stored and compared in memory
- Write a for loop to iterate over an array
- Write a for-in loop to iterate over an object
- Describe common native methods for arrays and objects
- Write a deeply nested object
- Read data from a deeply nested object
Answer in your slate:
- Create and assign an empty array to a variable
- Create and assign an array with the values 1,2,3 to a variable
- Create and assing an empty object to a variable
- Create and assign an object with key of 'name' and a value of 'Roger'
- Given the array
var ar = [1,2,3,4], access the 2nd value in the array? - Given the array
var ar = [1,2,3,4], change the 1st value in the array to 0 - Given the object
var obj = { name: 'Roger' }, access the value of the key 'name' - Given the object
var obj = { name: 'Roger' }, change the value of the key 'name' to be 'Charlemagne'
Turn to your neighbor and explain the difference between dot notation and bracket notation. Be prepared to share your answer with the class.
- Turn to your neighbor and explain how objects are stored in memory. Be prepared to share your answer with the class.
- Turn to your neighbor and explain how objects are compared. Be prepared to share your answer with the class.
In your slate, write a for loop to print out the contents of the following array
var arr = [1,2,3,4,5,6]
In your slate, write a for-in loop to print out the values of the following object.
var obj = { name: 'Roger', hair: true, shirt: 'plaid', glasses: false, age: 33 }
Turn to your neighbor and describe methods for arrays and objects. Be prepared to share with the class
- What is an example of data that could be expressed in a nested objects
- On your desks, write a deeply nested object.
- On your slate, write down how to access a key/value in your deeply nested object.