JS Functions Flashcards
What is a function in JavaScript?
a set of statements in a block of code that performs a task, and is executed by invoking
Describe the parts of a function definition
function myFunc(parameters) { // code block return statement }
Describe the parts of a function call
myFunc(arguments)
When comparing them side-by-side, what are the differences between a function call and a function definition?
definition = declaring the function and setting up the code block call = executing the function
What is the difference between a parameter and an argument?
paramenters are placeholders for values and arguments are the actual values you pass to the function
Why are function parameters useful?
allow the function to take a value from one scope and pass it to another scope
What two effects does a return statement have on the behavior of a function?
- lets the function create a value for use in the program
- any code after the return statement is not executed