javascript functions Flashcards
What is a function in JavaScript?
Functions allow you to package up code for use later in your program.
Describe the parts of a function definition.
Function keyword the optional function name parameters ( zero or more ) Code block optional return statement
Describe the parts of a function call.
function name
Parentheses
arguments
When comparing them side-by-side, what are the differences between a function call and a function definition?
in a definition we define parameters
In a call we pass arguments
What is the difference between a parameter and an argument?
parameter is a place holder
Argument is a value being passed into the function
Why are function parameters useful?
they allow for different arguments or values to be passed into the function
What two effects does a return statement have on the behavior of a function?
it stops the function’s code block / exits the function
causes the function to produce a value