JavaScript Functions Flashcards
What is a function in JavaScript?
A block of code that may or may not return something in the code when it is called
Describe the parts of a function definition.
Function ‘funtionname’ (parameter) {
rules
return;
}
Describe the parts of a function call.
contains the function name followed by the list of values that are assigned to the parameter’s in place
When comparing them side-by-side, what are the differences between a function call and a function definition?
define is when the code is written and just exists while the call is when it is interpreted by the code
What is the difference between a parameter and an argument?
Function parameters are the names listed in the function’s definition. Function arguments are the real values passed to the function.
Why are function parameters useful?
allow a function to perform tasks without knowing the specific input values ahead of time
What two effects does a return statement have on the behavior of a function?
It causes the function to return a value you can use in the program and prevents any more code in the functions block from being run