JavaScript Functions Flashcards
What is a function in JavaScript?
A set of scripts for the browser to run when the function is called(?)
Describe the parts of a function definition.
The function keyword, an optional name for the function, parameter list surrounded by parentheses, the start of the function code block, optional return, and the end of the function code block
Describe the parts of a function call.
the function name, arguments used within the parentheses
When comparing them side-by-side, what are the differences between a function call and a function definition?
the keyword is missing and there is no code block
What is the difference between a parameter and an argument?
the parameter is used when defining a function while an argument is used when calling a function
Why are function parameters useful?
it is useful as a placeholder for inputting values into a functions code block
What two effects does a return statement have on the behavior of a function?
Causes the function to produce a value we can use in our program.
Prevents any more code in the function’s code block from being run.