javascript-functions Flashcards

1
Q

What is a function in JavaScript?

A

It is a set of statements that performs a task or calculates a value that can take 0 or more input and has the option to return 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
  1. The function keyword
  2. An optional name
  3. zero or more parameters
  4. a code block
  5. an 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
  1. function’s name

2. comma-separated list of zero or more arguments surrounded by () parentheses

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

Defining a function details the steps of the task to perform while calling a function runs the code and performs the task.

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

The parameter is the variable name and the argument is the value.

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

Why are function parameters useful?

A

Parameters allow us to pass information or instructions into functions and procedures.

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. produces a value

2. exits a function block and no code after the statement is executed

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