Javascript-functions Flashcards

1
Q

What is a function in JavaScript?

A

A function is a set of codes that can perform a task and can be used repeatedly.

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

It consists of a function keyword, a function name, zero or more parameters surrounded by parentheses and separated by commas, and the curly braces to contain the function code block.

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

function name, parentheses with zero or more 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

A function definition starts with a function keyword, function name with zero or more parameters, then the curly braces to contain the function code block. A function call only needs the function name, followed by the parentheses to contain zero or more 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 like a placeholder, like a variable whose value is unknown. An argument is the value we 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

you van pass many different values to the function to produce different outcomes.

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

1) it causes the function to produce a value.

2) prevent other codes in the function code block from being run.

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