javascript-functions Flashcards
What is a function in JavaScript?
A function is a block of code that allows for code reusability, makes code easier to read, and makes coding “dynamic” as well as DRY.
Describe the parts of a function definition.
The parts of a function definition are: function name (*parameter1, *parameter2) { return result or value; }
Describe the parts of a function call.
The parts of a function call are: function name (*arg1, *arg2);
When comparing them side-by-side, what are the differences between a function call and a function definition?
The differences between a function call and a function definition are: a function definition makes an object with code that is awaiting runtime, a function call is taking a function object and running the code inside it. A function call used arguments and a function definition used parameters. A function call returns a value and is an expression.
What is the difference between a parameter and an argument?
A parameter is a placeholder for the future value of the argument being passed to that function. A function call uses arguments and a function definition uses parameters.
Why are function parameters useful?
Function parameters allow data to enter the scope and block of code within the function, be manipulated or stored, and returned. It allows one block of code to be slightly varied depending on the argument passed in.
What two effects does a return statement have on the behavior of a function?
Two effects a return statement has on the behavior of a function are: it instantaneously exits that function and does not run any code after the return it also gives whatever value was put after the return to the location that called the function.