javascript functions Flashcards

1
Q

What is a function in javascript?

A

A statement that performs a task or calculates a value.

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

Declaring function and a variable name (optional) and an opening curly brace for the start of the function. The statement, and a closing curly brace to close the function.

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

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

A

Defining a function telling what the function will do when arguments are plugged in. Calling the function only needs the variable and the arguments.

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

What is the difference between a parameter and an argument?

A

A parameter is a placeholder for arguments to be used in the function, and arguments are calling the function and plugging the values in.

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

Why are function parameters useful?

A

It lets the function know where to plug in arguments. If there are no parameters, the function cannot do anything.

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

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

A
  1. Causes the function to produce a value we can use in our program.
  2. Prevents any more code in the function’s code block from running
How well did you know this?
1
Not at all
2
3
4
5
Perfectly