javascript-constructors Flashcards
1
Q
What does the new operator do?
A
- new creates a blank js object
- links constructors to new object by setting another object as its parent prototype
- passes newly created object from step 1 as this context
- returns this if the function doesn’t return an object
2
Q
What property of JavaScript functions can store shared behavior for instances created with new?
A
prototype
3
Q
What does the instanceof operator do?
A
tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object