javascript-functions Flashcards
What is a function in JavaScript?
a function in javaScript is a tool that lets you package lines of code that perform a certain task, then get’s names so it can be reused more than once.
Describe the parts of a function definition.
function keyword followed by the function’s optional name followed by parentheses that house a/multiple parameters (variables). followed by curly braces that signify the start of the code block. and within the braces there is code
function add() {}
Describe the parts of a function call.
name of the function directly followed by an argument/s (if it accepts any), followed by a semi colon
When comparing them side-by-side, what are the differences between a function call and a function definition?
a function call does not include the function keyword.
a function call is passed with an argument, not a parameter.
What is the difference between a parameter and an argument?
A parameter is not real data.
A parameter is only included in the function definition.
An argument is only included when calling the function
An argument is real input.
Why are function parameters useful?
A parameter acts as a placeholder for an argument. they serve as a reminder for the type of data that should be passed as arguments when the function is called. A single tool that allows your function to be used in many situations
What two effects does a return statement have on the behavior of a function?
a return statement exits the function and causes a function to produce a value that can be used outside of the function