javascript-constructors Flashcards

1
Q

What does the new operator do?

A
  1. Make a new object
  2. Make new object prototype the prototype of constructor if possible
  3. Set this value to new object
  4. Typically the new object is returned, but if the constructor returns something then replace previous steps with the return value
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

The prototype property of JS functions can store shared behavior for instances created with new.

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

What does the instanceof operator do?

A

The instanceof property checks if an object has the same prototype of a constructor or any of the prototypes inherited by the constructor through the prototype chain.

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