Javascript-functions Flashcards
What is a function in JavaScript?
group of actions that are repeatable
Describe the parts of a function definition.
function keyword, optional function name, parenthesis (to pass on parameters) , opening braces, code block, and within the code block we have return statements and closing braces
Describe the parts of a function call.
function name with parenthesis (includes arguments).
When comparing them side-by-side, what are the differences between a function call and a function definition?
- Function call has argument while function definition has parameter passed on to it.
- function call does not have opening curly braces for code block.
- function definition has function keyword, but function call does not have it.
What is the difference between a parameter and an argument?
There are no values in parameters (It is still a variable),
The value only comes when that function is called.
The value is the argument.
Why are function parameters useful?
We get to use it many times, and also pass different argument as values. (mutability –> piece of function that can vary depending on the argument that is passed on).
What two effects does a return statement have on the behavior of a function?
- Stops the function block of code entirely.
2. Can see the value in our program.