Literal (Definition)

Constant values used to initialize or assign a value.

Literals are constant values used in assignments or as arguments to functions or expressions. A literal is considered to be a primary expression when it is being evaluated.

There are several kinds of literals. They are all based on the primitive types. The ECMA standard defines four basic data types, which should be sufficient for most purposes; however, a hosted interpreter may provide other more esoteric primitive values. Here are the four core standard types:

These are objects that can also be manufactured from literals:

String literals also include escaped character literals which may also be used in regular expressions.

Host environments additionally define others for special purposes depending on the implementation.

See also:Boolean literal, Character constant, Constant, Lexical element, Null literal, Numeric literal, Primary expression, String literal, Token

Cross-references:

ECMA 262 edition 2 - section - 7.7

ECMA 262 edition 2 - section - 11.1.3

ECMA 262 edition 3 - section - 7.8

ECMA 262 edition 3 - section - 11.1.3

O'Reilly JavaScript Definitive Guide - page - 30