Javascript-functions Flashcards

1
Q

What is a function in JavaScript?

A

group of actions that are repeatable

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 keyword, optional function name, parenthesis (to pass on parameters) , opening braces, code block, and within the code block we have return statements and closing braces

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 with parenthesis (includes 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
  1. Function call has argument while function definition has parameter passed on to it.
  2. function call does not have opening curly braces for code block.
  3. function definition has function keyword, but function call does not have it.
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

There are no values in parameters (It is still a variable),
The value only comes when that function is called.
The value is the argument.

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

Why are function parameters useful?

A

We get to use it many times, and also pass different argument as values. (mutability –> piece of function that can vary depending on the argument that is passed on).

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. Stops the function block of code entirely.

2. Can see the value in our program.

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