Javascript-functions Flashcards
What is a function in JavaScript?
A function is a set of codes that can perform a task and can be used repeatedly.
Describe the parts of a function definition.
It consists of a function keyword, a function name, zero or more parameters surrounded by parentheses and separated by commas, and the curly braces to contain the function code block.
Describe the parts of a function call.
function name, parentheses with zero or more arguments.
When comparing them side-by-side, what are the differences between a function call and a function definition?
A function definition starts with a function keyword, function name with zero or more parameters, then the curly braces to contain the function code block. A function call only needs the function name, followed by the parentheses to contain zero or more arguments.
What is the difference between a parameter and an argument?
parameter is like a placeholder, like a variable whose value is unknown. An argument is the value we pass to the function.
Why are function parameters useful?
you van pass many different values to the function to produce different outcomes.
What two effects does a return statement have on the behavior of a function?
1) it causes the function to produce a value.
2) prevent other codes in the function code block from being run.