javascript-functions Flashcards
What is a function in JavaScript?
Collection of instructions that can be repeated.
Describe the parts of a function definition.
- Function keyword;
- Function name (optional);
- Zero or more parameters;
- Code block enclosed within { };
- Return (optional) statement.
Describe the parts of a function call.
- Function name;
2. Zero or more arguments within ( ).
When comparing them side-by-side, what are the differences between a function call and a function definition?
Function call takes arguments and function definition takes parameters and has the code block.
What is the difference between a parameter and an argument?
Parameters are passed when defining the function and arguments are passed when calling the function.
Why are function parameters useful?
Makes the functions more dynamic.
What two effects does a return statement have on the behavior of a function?
Produces a value from the function and everything after the return statement is ignored.