Javascript Functions Flashcards
What is a function in javascript ?
Code that performs a task and can be reused later in a program
Describe the parts of a function definition.
-Function Keyword
-Optional name
-Comma separated list of 0 or more parameters surrounded by parenthesis
-Start of function code block followed by opening curly brace
-Optional return statement and end of code block closing curly brace
Describe the parts of a function call.
-Function name-Comma separated list surrounded by parenthesis
When comparing side by side what are the differences between a function call and a function definition ?
Function calls are running the function where as function definition is simply defining what the function should do
What is the difference between a a parameter and an argument ?
Parameter is a placeholder, argument is a value
Why are function parameters useful ?
They allow functions to be customizable
What two effects does a return
statement have on the behavior of a function ?
Produces a value that can be used in a program and prevents any code from being executed after the return statement