javascript-functions Flashcards

1
Q

What is a function in JavaScript?

A

Collection of instructions that can be repeated.

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
  1. Function keyword;
  2. Function name (optional);
  3. Zero or more parameters;
  4. Code block enclosed within { };
  5. Return (optional) 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
  1. Function name;

2. Zero or more arguments within ( ).

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 call takes arguments and function definition takes parameters and has the code block.

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

Parameters are passed when defining the function and arguments are passed when calling 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

Makes the functions more dynamic.

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

Produces a value from the function and everything after the return statement is ignored.

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