JS Functions Flashcards

1
Q

What is a function in JavaScript?

A

a set of statements in a block of code that performs a task, and is executed by invoking

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 myFunc(parameters) {
       // code block
       return statement
}
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

myFunc(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
definition = declaring the function and setting up the code block
call = executing the function
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

paramenters are placeholders for values and arguments are the actual values you pass 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 the function to take a value from one scope and pass it to another scope

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
  • lets the function create a value for use in the program

- any code after the return statement is not executed

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