objects Flashcards

1
Q

describe how to retrieve values from an object (both ways)

A

objectName.property

objectName[“key”]

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

what’s the syntax for updating or adding values to an object (both ways)

A
objectName.key = value;
objectName["key"] = value;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
const student = {
  firstName : 'David',
  lastName  : 'Jones',
  strengths : ['Art', 'English'],
  exams : {
    midterm1 : 92,
    midterm2 : 89,
    final    : 98
  }
}

how would you access ‘English’?

A

student.strengths[1];

// access element in an array, nested in an object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
const student = {
  firstName : 'David',
  lastName  : 'Jones',
  strengths : ['Art', 'English'],
  exams : {
    midterm1 : 92,
    midterm2 : 89,
    final    : 98
  }
}

how would you access the midterm2 score, 89?

A

student.exams.midterm2;

// access value in an object, nested in another object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
const student = {
  firstName : 'David',
  lastName  : 'Jones',
  strengths : [
    ['P.E.', 'Art'],
    ['Science', 'English']
  ],
  exams : {
    midterm1 : 92,
    midterm2 : 89,
    final    : 98
  }
}

how would you access ‘Science’?

A

student.strengths[1][0];

// access element in a nested array, nested in an object

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