The Secret Life of Objects Flashcards

1
Q

Encapsulation

A

Distinguishing between internal complexity and external interface.

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

What is a method?

A
Properties that hold function values.
rabbit.special = function(arg) {
//statement
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

T or F: Almost all objects have prototypes.

A

True

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

What is a prototype?

A

Another object that is used as a fallback source of properties.

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

What happens when an object gets a request for a property that it does not have?

A

Its prototype will be searched for the property, then the prototype’s prototype, and so on.

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

Object.create()

A

Creates an object with a specific prototype in the argument.

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

Calling a function with the “new” keyword in front of it causes it to be treated as a _______.

A

Constructor

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

An object created with the “new” keyword is said to be an ______ of its constructor.

A

instance

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

What should you always do when naming a constructor so it can be easily distinguished from other functions?

A

Capitalize the first letter of the constructor name.

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

Constructors (all functions) automatically get a property named _____.

A

prototype

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

By default, prototypes created through constructors get?

A

a plain, empty object that derives from Object.prototype. Every instance created with this constructor will have this object as its prototype.

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

Object’s prototype can be retrieved with?

A

Object.getPrototypeOf

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

The actual prototype of a constructor is?

A

Function.prototype (since constructors are functions)

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

Can instance object’s properties override it’s prototype properties?

A

Yes

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

What are enumerable properties?

A

Properties that we create by simply assigning to them.

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

The standard properties in Object.prototype are enumerable or non-enumerable?

A

non-enumerable.

17
Q

How can we define our non-enumerable properties?

A

Object.defineProperty() function. Allows us to control the type of property we are creating.

18
Q

What does the “hasOwnProperty()” method do?

A

Tells us whether the object itself has the property, without looking at its prototype.