JavaScript Objects Flashcards
Objects can be used if _____ properties can be given to multiple _____. (syntax)
var myCar = new Object();
Literal syntax
var myCar = {};
You can assign and retrieve property values using dot syntax (syntax)
myCar.make = "Ford"; myCar.model = "Mustang"; myCar.year = 1969;
OR using ______ syntax:
var myCar = {make:"Ford", model:"Mustang", year:1969}; console.log(myCar.model);
Both _____ and ____ can hold multiple pieces of data. However, if a piece of data can be referenced by a _____ property, then an object can be used to make the data structure more _________.
Both objects and arrays can hold multiple pieces of data. However, if a piece of data can be referenced by a named property, then an object can be used to make the data structure more descriptive.
Arrays with ______ indexes do not have this benefit. Arrays are a lightweight container for holding multiple pieces of data, especially collections of things.
Arrays with numeric indexes do not have this benefit. Arrays are a lightweight container for holding multiple pieces of data, especially collections of things.
Objects can be made up of ______ properties like _____, _____, ______ etc. as well as other objects and arrays. Arrays can be made up of objects or other arrays and scalar values.
Objects can be made up of scalar properties like strings, integers, booleans etc. as well as other objects and arrays. Arrays can be made up of objects or other arrays and scalar values.
Give an example of a complex object (syntax)
{ name:"Oakville Public Library", services:["Borrowing", "Internet", "Meeting Rooms", "Comunity"], address:{ street:"120 Navy St.", town:"Oakville", province:"Ontario", postalCode:"L6J 2Z4" }, books:[ { pages:"198", author:"Neil Young", title:"Waging Heavy Peace" }, { pages:"1", author:"Matthew Inman", title:"How to Tell If Your Cat Is Plotting to Kill You" }, { pages:"234", author:"Tyler Hamilton", title:"The Secret Race" } ] };