javascript-functions Flashcards
What is a function in JavaScript?
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.
Describe the parts of a function definition.
- The function keyword
- An optional name
- zero or more parameters
- a code block
- an optional return statement
Describe the parts of a function call.
- function’s name
2. comma-separated list of zero or more arguments surrounded by () parentheses
When comparing them side-by-side, what are the differences between a function call and a function definition?
Defining a function details the steps of the task to perform while calling a function runs the code and performs the task.
What is the difference between a parameter and an argument?
The parameter is the variable name and the argument is the value.
Why are function parameters useful?
Parameters allow us to pass information or instructions into functions and procedures.
What two effects does a return statement have on the behavior of a function?
- produces a value
2. exits a function block and no code after the statement is executed