JavaScript Objects Flashcards

1
Q

Objects can be used if _____ properties can be given to multiple _____. (syntax)

A

var myCar = new Object();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Literal syntax

A

var myCar = {};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

You can assign and retrieve property values using dot syntax (syntax)

A
myCar.make = "Ford"; 
myCar.model = "Mustang"; 
myCar.year = 1969;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

OR using ______ syntax:

A
var myCar = {make:"Ford", model:"Mustang", year:1969};
console.log(myCar.model);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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 _________.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Arrays with ______ indexes do not have this benefit. Arrays are a lightweight container for holding multiple pieces of data, especially collections of things.

A

Arrays with numeric indexes do not have this benefit. Arrays are a lightweight container for holding multiple pieces of data, especially collections of things.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Give an example of a complex object (syntax)

A
{
 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"
   }
  ]
 };
How well did you know this?
1
Not at all
2
3
4
5
Perfectly