Object-Oriented Programming Flashcards

1
Q

What is a method?

A

a method is a function which 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 method definition and a method call?

A

method call does not have a code block

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

Describe method definition syntax (structure).

A

method: function( ) { }

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

Describe method call syntax (structure).

A

Object.method( )

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

method is associated with object, function is not

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

What is the defining characteristic of Object-Oriented Programming?

A

objects can contain both data (as properties) and behavior (as methods)

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

simplifying complex behavior

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

connects computers and programs to each other

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

What is ‘this’ in JavaScript?

A

implicit parameter of all JavaScript functions

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

What does it mean to say that this is an “implicit parameter”?

A

it is available in a function’s code block even though it was never included in the function’s parameter list

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

When is the value of this determined in a function; call time or definition time?

A

call

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

How can you tell what the value of this will be for a particular function or method definition?

A

you can’t

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

How can you tell what the value of this is for a particular function or method call?

A

the object 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

prototype-based or prototypal

17
Q

What is a prototype in JavaScript?

A

the mechanism by which JavaScript objects inherit features from one another

18
Q

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

A

they come with built in prototype objects

19
Q

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

A

on the prototypes

20
Q

What does the new operator do?

A
  • create an instance of a user-defined object type
  • adds a property to the new object (__proto__) that links to the constructor function’s prototype object
  • binds the newly created object instance as the this context
  • returns this if the function doesn’t return an object
21
Q

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

A

prototype

22
Q

What does the instanceof operator do?

A

tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object. The return value is a boolean value.