JavaScript Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 2.00

Primitive Data Types - Numbers, Strings, and Booleans

This section provides a quick description of JavaScript primitive data types, numbers, strings, and booleans.

JavaScript supports 5 primitive data types:

  • Numbers - Any types of numeric values including integers and floating point values. Examples of numbers are: 2008, 3.14, 1.51e10, etc.
  • Strings - Sequences of Unicode characters. Examples of strings are: "Hello World!", "2008", "\u4E16\u754C\u4F60\u597D\uFF01", etc.
  • Booleans - Two values only: true and false.
  • Null - One value only: null.
  • Undefined - One value only: undefined.

JavaScript is a dynamic typing language. Data types are associated with values, instead of variables. In other words, variables are declared without specific data types. They can be assigned with values of any data type.

In JavaScript source code, values of different data types can be provided as value literals as described in sections below.

Sections in This Chapter

Primitive Data Types - Numbers, Strings, and Booleans

Numeric Value Literals

String Literials

Declaring Variables - "var" Statements

Operators and Expressions

Operators and Expressions - Examples

Dr. Herong Yang, updated in 2008
Primitive Data Types - Numbers, Strings, and Booleans