Object Oriented JavaScript & Prototypal Inheritance Flashcards

1
Q

Inheritance

A

One object gets access to the properties and methods of another object. (There’s an object and another object, an the other object can get access to the first object’s methods and properties.)

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

Classical Inheritance

A

Verbose. A large collection of object’s properties and methods.

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

Prototypal Inheritance

A

Simpler than classical inheritance. It’s flexible, extensible, and easier to understand.

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

Objects can have

A

properties and methods.

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

Everything in JavaScript except for _____ are objects.

A

primitives: numbers, strings, booleans, undefined, null.

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

Reflection

A

An object can look at itself, listing and changing its properties and methods.

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

Every constructor we initialize gets a free ______ object as one of its properties.

A

prototype

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

What is object-oriented programming?

A

Objects interacting with one another through methods and properties. Used to store data, structure applications into modules and keeping code clean.

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

Constructors act like a ________.

A

blueprints

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

Inheritance is made possible because of the ______ that every object has.

A

prototype

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

How does inheritance actually work?

A

prototype chain. When you try to access method or property on a object, JS will first try to find it in that object.. if it can’t find it, then it looks at the parent’s object, if the method is still not there, it continues to look at the upper objects until it’s null/undefined.

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

Every JavaScript object has a ______ _____, which makes inheritance possible in JavaScript.

A

prototype property

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

The prototype property of an object is where we put methods and properties that we want other objects to _____.

A

inherit

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

The constructor’s prototype property is NOT the prototype of the Constructor itself, it’s the prototype of ALL _______ that are created through it.

A

instances

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

When a certain method (or property) is called, the search starts in the object itself, and if it cannot be found, the search moves on to the object’s prototype. This continues until the method is found. This is called?

A

The prototype chain

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

What type of object is this?

let john = {
  name: 'john',
  yearOfBirth: 1990,
  job: 'teacher'
};
A

object literal

17
Q

function constructor’s variable name always starts with a…

A

capital

18
Q
what does the new operator do?
new Person();
A

a new empty object is created then the function is called

19
Q

Reflection

A

An object can look at itself, listing and changing its properties and methods.

20
Q

_.extend

A

??