OOP Flashcards

1
Q

What is amethod?

A

A function that is a property of an object

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

How can you tell the difference between a methoddefinitionand a methodcall?

A

Method definition is a shorter syntax for defining a function property in an object initializer.

Method call has an argument

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

Describe methoddefinitionsyntax (structure).

A

Var object = {
method() {
return ‘something’
}
};

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

Describe methodcallsyntax (structure).

A

methodName(argument);

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

How is a method different from any other function?

A

A method is associated with an object, while a function is not
Usually a method is group with other similar properties

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

What is thedefining characteristicof Object-Oriented Programming?

A

It stores data in objects to create better structured and reusable code

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

What are the four “principles” of Object-Oriented Programming?

A

Abstraction, Encapsulation, Inheritance, Polymorphism

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

What is “abstraction”?

A

The idea of breaking down something that is complex into simpler terms

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

What does API stand for?

A

Application Programming Interface

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

What is the purpose of an API?

A

To allow two or more programs to communicate with each other

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

What isthisin JavaScript?

A

“This” is the object that a method called with

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

What does it mean to say thatthisis an “implicit parameter”?

A

It is available in the code block even through it was never included in the function’s definition

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

Whenis the value ofthisdetermined in a function;call timeordefinition time?

A

The value of “this” is determined when the function is called

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

How can you tell what the value ofthiswill be for a particular function or methoddefinition?

A

You can’t tell?

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

How can you tell what the value ofthisis for a particular function or methodcall?

A

look at the object name to the left of the dot

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

What kind of inheritance does the JavaScript programming language use?

A

Prototypal inheritance (objects inherit from other objects)

17
Q

What is a prototype in JavaScript?

A

an object that contains properties and (predominantly) methods that can be used by other objects.

18
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

The methods are defined on a prototype object and those methods are borrowed as needed

19
Q

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

A

In the objects prototype chain
It will go down prototype chain until it runs out of things to look at
If there’s nothing, it returns undefined

20
Q

What does thenewoperator do?

A

It creates an instance of a user defined object or one of the constructor objects

21
Q

What property of JavaScript functions can store shared behavior for instances created withnew?

A

AFunctionobject’sprototypeproperty is used when the function is used as a constructor with thenewoperator.