javascript functions Flashcards

1
Q

What is a function in JavaScript?

A

Functions allow you to package up code for use later in your program.

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 
the optional function name 
parameters ( zero or more )
Code block 
optional 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

function name
Parentheses
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

in a definition we define parameters

In a call we pass 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 a place holder

Argument is a value being passed into 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

they allow for different arguments or values to be passed into the function

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

it stops the function’s code block / exits the function

causes the function to produce a value

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