Functions Flashcards
What are “ Functions “?
A function is a block of code designed to perform a particular task.
A function is executed when “something” invokes it (calls it).
How do you declare a Function?
The function keyword goes first, then the function name, then a list of parameters between the parentheses, and then the code of the function between curly braces.
How do you call a function?
A function can be called using it’s name.
What are “ Local “ variables?
A variable declared inside a function is Local and only visible inside that function.
What are “ Global/Outer “ variables?
Variables declared outside of a function are called global and are visible from any function.
What is a “ Parameter “?
A parameter is the variable listed inside the parentheses in the function declaration. In this example, (from, text).
What is a “ Argument “?
An argument is the value that is passed to the function parameter when it is called. In this example, (“Ann”, “Hello”).
What is a default value?
A default value can be specified in the function declaration. This value will be used if argument is not specified in the function call.
What is the preferred way to name a function?
Functions are actions. So their name is usually a verb. It should be brief, as accurate as possible and describe what the function does.