object orientated programing Flashcards

1
Q

What is a method?

A

a function that is associated with 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 definition starts with the function keyword, method call has the parantheses and an argument

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

Describe method definition syntax (structure).

A

property name colon and 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 name and method name and then function plus arguments

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

methods are associated with objects,

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

object oriented programing relies on encapsulation/ grouping similar values and functions or methods all in one place

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

What is “abstraction”?

A

simplifying complex things

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
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
9
Q

What is the purpose of an API?

A

it is the connection between programs and computer hardware, to allow someone else to interact with your program

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

it is the connection between programs and computer hardware, to allow someone else to interact with your program.

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

What is this in JavaScript?

A

his keyword refers to the object it belongs to

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

An implicit parameter is opposite to an explicit parameter, which is passed when specifying the parameter in the parenthesis of a method call.

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 time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
What does this refer to in the following code snippet?
var character = {
  firstName: 'Mario',
  greet: function () {
    var message = 'It\'s-a-me, ' + this.firstName + '!';
    console.log(message);
  }
};
A

the character object

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

Given the above character object, what is the result of the following code snippet? Why?
character.greet();

A

its a me mario

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

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

inheritance, they inherited those methods

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

at its prototype

20
Q

What does the new operator do?

A

creates an empty js object, adds a proto keyword to object, it binds the new instance as ‘this’, it returns this

21
Q

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

A

prototype property

22
Q

What does the instanceof operator do?

A

The instanceof operator 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.