javascript-constructors Flashcards

1
Q

What does the new operator do?

A
  1. Creates a blank, plain JavaScript object;
  2. Links (sets the constructor of) the newly created object to another object by setting the other object as its parent prototype;
  3. Passes the newly created object from Step 1 as the “this” context;
  4. Returns “this” if the function doesn’t return an 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

It checks if a prototype property appears anywhere in the prototype chain of an object.

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