javascript functions Flashcards
What is a function in javascript?
A statement that performs a task or calculates a value.
Describe the parts of a function definition
Declaring function and a variable name (optional) and an opening curly brace for the start of the function. The statement, and a closing curly brace to close the function.
When comparing them side-by-side, what are the differences between a function call and a function definition?
Defining a function telling what the function will do when arguments are plugged in. Calling the function only needs the variable and the arguments.
What is the difference between a parameter and an argument?
A parameter is a placeholder for arguments to be used in the function, and arguments are calling the function and plugging the values in.
Why are function parameters useful?
It lets the function know where to plug in arguments. If there are no parameters, the function cannot do anything.
What are 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 running