javascript-functions-intro Flashcards
1
Q
What is a function?
A
set of code that can be grouped together and reused.
2
Q
Why are functions useful?
A
Allow you to store a piece of code that does a single task inside a defined block, and then call that code whenever you need it using a single short command
3
Q
How do you call a function?
A
a method with an owner object as an argument (parameter)
4
Q
What are the parts of a function definition?
A
- keyword
- optional name
- parameters()
- statement enclosed in braces {}
5
Q
What is the difference between a parameter and an argument?
A
Function parameters are the names listed in the function’s definition. Function arguments are the real values passed to the function.