Menu

Javascript Values

A piece of information in JavaScript is a value. There are different kinds of values, for example numbers or strings. A string value is a word or words enclosed in quotation marks.

Variables contain values. For example the variable siteName is assigned the string “HTMLcenter”: siteName = "HTMLcenter", where the equals sign means “set to”. The variable siteName now contains the value HTMLcenter.

Keep in mind that JavaScript is case sensitive. Variable MyName is not the same as myName or myname. Variables can not contain spaces and you shouldn’t choose one of the JavaScript reserved words as name for a variable.

Values:

  • Number – any numeric value, e.g. 1.23456789
  • String – characters in quotes, e.g. "Hi, HTMLcenter!"
  • Boolean – true or false, e.g. false
  • Null – empty / no meaning: null
  • Object – any value associated with an object
  • Function – value returned by a function