Javascript-constructors Flashcards

1
Q

What does the new operator do?

A
  1. Creates instance of an object (blank object)
  2. links it to this. (sets the constructor object to the parent prototype)
  3. and it also returns this.
  4. sets the prototype.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What property of JavaScript functions can store shared behavior for instances created with new?

A
  1. prototype property.

(mainly it is to preserve memory) –> for optimization.

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

What does the instanceof operator do?

A
  1. it checks if the left thing is the value of the right. (will return a boolean).
  2. checks to see if there is any prototype property is anywhere in the prototype chain
How well did you know this?
1
Not at all
2
3
4
5
Perfectly