0220 js custom methods Flashcards

1
Q

What is a method?

A

A method is a function which is a property of an object.

more: There are two kinds of methods: instance methods which are built-in tasks performed by an object instance, or static methods which are tasks that are called directly on an object constructor.

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

definition has the word function, but calling does not

definitions have parameters, but calling has arguments

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

Describe (or write or type out) method definition syntax (structure).

A

here is an object:
var doggo = {
bork: function () {
return ‘bork! bork! bork!’;
},
lick: function () {
return ‘mlem’;
}
};

the function is this part:
bork: function () {
return ‘bork! bork! bork!’;
},

the property is listed as per usual, with a colon, with no parameters.
next, the word “function” is written, with brackets
next any parameters are typed into the brackets, separated by commas
next, opening curly brace
then the code block with possible return statement
next, closing curly brace

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

Describe method call syntax (structure).

A

e.g.
doggo.bork( );

type the object
then type the property
then type the brackets with any necessary 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

it is a property of an object as opposed to a standalone function

it can only be used as part of an object

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

a simple way of being able to work with (possibly) complex things

e.g. i click on a pic link but the computer is actually doing a gazillion things to render the pic.
i don’t have to do those things. i just need to click!

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 (API)

extra:
it is a way for two or more computer programs to communicate with each other

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

the purpose of every software API is to give programmers a way to interact with a system in a simplified, consistent fashion: aka, an abstraction

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

what is an anonymous function

A

a function without a name

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