js functions Flashcards
What is a function in JavaScript?
an operation that can take in parameters and returns something, can be called as needed
Describe the parts of a function definition.
function myFunction(parameter, anotherParameter) { code goes here; return; }
Describe the parts of a function call.
myFunction(argument, anotherArgument);
When comparing them side-by-side, what are the differences between a function call and a function definition?
definition has function keyword, parameters, and body of code; call has arguments
What is the difference between a parameter and an argument?
function definitions have parameters, calls have arguments. parameters are like placeholders
Why are function parameters useful?
they allow us to pass data/info into a function, making functions more dynamic and versatile
What two effects does a return statement have on the behavior of a function?
returns a value from the function, and exits out of the function without running any more of the code