Javascript Prototypes Flashcards

1
Q

What kind of inheritance does the JavaScript programming language use?

A

Parent organisms give traits to their offspring through their DNA. JavaScript includes a specific kind of inheritance known as prototype-based (or prototypal) inheritance. JavaScript objects give certain behaviors (methods) or data (properties) to other objects.

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

What is a prototype in JavaScript?

A

As mentioned before, a JavaScript prototype is simply an object that contains properties and (predominantly) methods that can be used by other objects. An object on which another object is based.

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

How is it possible to call methods on strings, arrays, and numbers even though those methods don’t actually exist on strings, arrays, and numbers?

A

They are baked in through prototypes which define the functions, inheritance from objects

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

If an object does not have it’s own property or method by a given key, where does JavaScript look for it?

A

prototype, if that prototype doesnt have it then the next prototype and so on. it is inherited

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