Javascript-constructors Flashcards
1
Q
What does the new operator do?
A
- Creates instance of an object (blank object)
- links it to this. (sets the constructor object to the parent prototype)
- and it also returns this.
- sets the prototype.
2
Q
What property of JavaScript functions can store shared behavior for instances created with new?
A
- prototype property.
(mainly it is to preserve memory) –> for optimization.
3
Q
What does the instanceof operator do?
A
- it checks if the left thing is the value of the right. (will return a boolean).
- checks to see if there is any prototype property is anywhere in the prototype chain