js constructors Flashcards
1
Q
What does the new operator do?
A
- creates blank JS object
- Adds propert to new object (__proto__) that links the constructor functions prototype object
- Binds newly created object as the this context
- Returns this if function doesn’t return 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
returns boolean that tests if prototype property of a constructor appears anywhere in prototype chain of the object