Javascript Functions Flashcards

1
Q

What is a function in javascript ?

A

Code that performs a task and can be reused later in a 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
-Optional name
-Comma separated list of 0 or more parameters surrounded by parenthesis
-Start of function code block followed by opening curly brace
-Optional return statement and end of code block closing curly brace

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-Comma separated list surrounded by parenthesis

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

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

A

Function calls are running the function where as function definition is simply defining what the function should do

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

What is the difference between a a parameter and an argument ?

A

Parameter is a placeholder, argument is a value

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 functions to be customizable

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 that can be used in a program and prevents any code from being executed after the return statement

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