js constructors Flashcards

1
Q

What does the new operator do?

A

lets developers create an instance of a user-defined object type or of one of the built-in object types that has a constructor function

  1. Creates a new object
  2. Sets the prototype of this object to the constructor function’s prototype property
  3. Binds the this keyword to the newly created object and executes the constructor function
  4. Returns the newly created object
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

prototype property

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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; boolean return value

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