A variable in JavaScript is a container used to store a piece of data (e.g. some text). When a variable is created, or ‘declared’, the assignment operator (=) can be used to define the data that is stored within the new variable. For example:
var myName = "Lee";
Alternatively, variables can be left blank to be assigned later through user action such as the completion of a form. Data obtained this way is referred to as “input”.