When you start up an environment (like turning on a computer or opening up a program), the values you find in that environment have the type function.
What is a function?
A function is:
- a portion of a program wrapped in a value
- performs a single task and you can call that function whenever you want
Take, for example, the binding prompt. It holds a function that shows a dialog box asking for a user’s input.
prompt("Enter passcode");
This prompt function uses the string “Enter passcode” that we made up and shows it on the dialog box.
Values that we give to functions are called arguments.
Here, we are invoking or calling a function named prompt. The argument is “Enter passcode.”
What does invoke, call, or apply mean in JavaScript?
Whenever we use the words invoke, call, or apply, it means we want to execute a function.
To invoke or call a function, you must put parentheses after an expression that produces a value.
Values provided to functions can be one or many or even different types from each other.