JavaScript Functions Flashcards

1
Q

What is a function in JavaScript?

A

A block of code that may or may not return something in the code when it is called

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

Describe the parts of a function definition.

A

Function ‘funtionname’ (parameter) {
rules
return;
}

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

Describe the parts of a function call.

A

contains the function name followed by the list of values that are assigned to the parameter’s in place

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

When comparing them side-by-side, what are the differences between a function call and a function definition?

A

define is when the code is written and just exists while the call is when it is interpreted by the code

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

What is the difference between a parameter and an argument?

A

Function parameters are the names listed in the function’s definition. Function arguments are the real values passed to the function.

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

Why are function parameters useful?

A

allow a function to perform tasks without knowing the specific input values ahead of time

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

What two effects does a return statement have on the behavior of a function?

A

It causes the function to return a value you can use in the program and prevents any more code in the functions block from being run

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