JavaScript – Literals

A literal is a data value that appears
directly in a program. The following are all literals:

12               // The number twelve
1.2              // The number one point two
"hello world"    // A string of text
'Hi'             // Another string
true             // A Boolean value
false            // The other Boolean value
/javascript/gi   // A "regular expression" literal (for pattern matching)
null             // Absence of an object

Complete details on numeric and string literals appear in ChapterĀ 3. Regular expression literals are covered in
ChapterĀ 10. More complex expressions (see Object and Array Initializers) can serve as array and object literals.
For example:

{ x:1, y:2 }    // An object initializer
[1,2,3,4,5]     // An array initializer

Comments are closed.