js functions Flashcards

1
Q

What is a function in JavaScript?

A

Block of code that can be 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 myfunction(param1, param2) { //code}
keyword function, name of function, arguments, curly braces, code
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
myFunction(arg1, arg2);
function name, parenthesis, arguments
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
function definition has function keyword and parameters
function call has arguments
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

parameter is a placeholder

arguments contain values that can be passed

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

Why are function parameters useful?

A

the function can then operate according to different situations

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

return will give the result of the function a value after the function is called
return will exit the function

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