Over a million developers have joined DZone.

Datatypes And Variables In Javascript

DZone's Guide to

Datatypes And Variables In Javascript

· ·
Free Resource
JavaScript variables have an identifier, scope, and a specific data type. Because the language is loosely typed, the rest, as they say, is subject to change without notice.

Variables in JavaScript are much like those in any other language; you use them to hold values in such a way that the values can be explicitly accessed in different places in the code. Each has an identifier that is unique to the scope of use (more on this later), consisting of any combination of letters, digits, underscores, and dollar signs. An identifier doesn’t have a required format, other than it must begin with a character, dollar sign, or underscore:


Starting with JavaScript 1.5, you can also use Unicode letters (such as �) and digits, as well as escape sequences (such as \u0009) in variable identifiers. The following are also valid variable identifiers for JavaScript:


Use special characters with caution, though, as some tools such as debuggers may have difficulty with them.

JavaScript is case-sensitive, which means it treats upper- and lowercase characters differently. For instance, JavaScript sees the following two variable identifiers as separate variables:


Spring Framework

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}