# Variables
# 1. Concept
- Variables in
ftsare all references to values. - Assigning a value to an undeclared variable directly will define it as a global variable.
- If a variable is declared but not assigned a value, its default value is
undefined. - The behavior of
varis consistent with JavaScript, including variable hoisting.
var foo = 1;
var bar = "hello world";
var i; // i === undefined
The code above declares three variables: foo, bar, and i. Then, foo is assigned the numeric value 1, and bar is assigned the string value "hello world".
# 2. Variable Names
Variable names must comply with the following two rules:
- The first character must be: a letter (a-zA-Z) or an underscore (_)
- The remaining characters can be: letters (a-zA-Z), underscores (_), or digits (0-9)
# 3. Reserved Identifiers
The following identifiers cannot be used as variable names:
delete
void
typeof
null
undefined
NaN
Infinity
var
if
else
true
false
require
this
function
arguments
return
for
while
do
break
continue
switch
case
default