Variables
...are
case-sensitive
, must begin with a
letter
,
dollar sign ($)
or a
underscore character
and contain no spaces... The variable should contain only letters, numbers, a dollar sign or underscore. number1 moms_phone_number $firstName _123test Not: 1number moms phone number "firstName"
x

Declaring variables
With the keyword
var
: var x = 42 (local or global variables). With the keyword
let
: let y = 13. (local variable).
JavaScript Variable Scope
Global
Variables - A global variable has global scope which means it can be defined anywhere in your JavaScript code.
Local
Variables - A local variable will be visible only within a function where it is defined. After a variable has been defined, its name can be used as an expression. The value of such an expression is the value the variable currently holds. Here is an example: var ten = 10; console.log(ten * ten); // ? 100 up