JavaScript Variable Types

From Techotopia
Revision as of 20:00, 11 April 2007 by Neil (Talk | contribs)

Jump to: navigation, search

JavaScript supports five different types of variable. These variable types are outlined in the following table together with a brief description of each type:

TypeExampleDescription
booleantrue, falseThe boolean variable is used to record a value of either true or false. Internally this is essentially stored as 1 for true and 0 for false.
number1, -31, 0.023The number variable holds any type of number, either an integer or a real number.
string"Hello World!"The string variable type stores a string of characters, typically making up either a word or sentence. string variables can also be assigned empty strings.
functionany user defined functionA function is one of the basic building blocks of most programming languages including JavaScript. Functions are used to break up a script into clean, reusable modules. Functions are covered in a later chapter.