Next: Scoping Rules
Up: Variables
Previous: Manipulating Variables
JavaScript has only four types
of data, (you do not declare the type in var):
- numeric
- :
- integers such as 2,22 and 2,222,000 or
- floating point values like 23.42, -56.01 and 2E45.
- No need to differentiate
between
- in fact variables can change
type within program.
- strings
- :
- collections of characters that are not numbers.
- All of the following are
strings:
"David",
"David Marshall"
"12345.432".
- put
quotes around the value to a assign a variable:
name = "David Marshall";
name = 'David Marshall';
str = "34.45";
- Boolean
- :
-
variables can hold the values true and false.
- used a lot in conditional tests (later).
- null
- :
- used when you don't yet know something.
- A null value means one that has
not yet been decided.
- It does not mean nil or zero and should NOT be used in
that way.
Dave Marshall
9/28/2001