Call a Function
nameOfFunc();
Function Declarations
function nameOfFunc(param1, param2) {
return param1>param2?param1:param2;
}
Function Expressions
var nameOfFunc = function(param1, param2) {
return param1>param2?param1:param2;
};
nameOfFunc();
Parameter – A variable in which the function stores information passed to it.
Argument – A value that you pass to a function when you call the function.
Scope
Scope is the context in which a variable can be accessed, such as within a function, or within the global scope of the entire program.
Function Scope
When you declare a variable within a function, that variable is only accessible within that function.
Global Scope
When a variable is accessible anywhere inside a program – in the body of the program and within functions.