Prototype Flashcards

1
Q

What kind of property does every JS object have?

A

Prototype property

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

What are the two ways prototype is being used for?

A

Inheritance & accessing properties on (different) objects

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

What is prototype property?

A

It is a built-in mechanism which every JS object has by which objects can inherit different methods and properties from one another

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

What does prototype attribute do?

A

Property attribute specifies the object from which it inherits properties

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

What is inheritance in programming? In JS, what do you use for that?

A

Inheritance is a system where objects can inherit properties and methods from other objects. In JS you use prototype for that

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

What’s the alias for prototype attribute?

A

Prototype object

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

If you want to access the property of an object, where does the search start and how does it go? At what point will the search end? How is it called?

A

It starts from the object itself, if the property ain’t there, it goes to the “parent” of that object (which is the object’s prototype), if it’s not there it’ll go to its prototype etcetc. The search continues until there aren’t anymore prototypes to go to.
It is called the prototype chain.

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

What can be used so that one object can inherit prototypes from another?

A

Object.create()

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

Why Obj1.prototype = Obj2.prototype is a bad idea?

A

Because now the Obj2 has been overwritten. We want to base Obj1 on Obj2 and not overwrite it

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