javascript-constructors Flashcards
1
Q
What does the new operator do?
A
- Make a new object
- Make new object prototype the prototype of constructor if possible
- Set this value to new object
- Typically the new object is returned, but if the constructor returns something then replace previous steps with the return value
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.
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.