2.6 LiteralsA 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 In ECMAScript v3, expressions that serve as array and object literals are also supported. For example: { x:1, y:2 } // An object initializer [1,2,3,4,5] // An array initializer Note that these array and object literals have been supported since JavaScript 1.2 but were not standardized until ECMAScript v3. Literals are an important part of any programming language, as it is impossible to write a program without them. The various JavaScript literals are described in detail in Chapter 3. |
•
Table of Contents
•
Index
•
Reviews
•
Examples
•
Reader Reviews
•
Errata
JavaScript: The Definitive Guide, 4th Edition
By
David Flanagan
Publisher
: O'Reilly
Pub Date
: November 2001
ISBN
: 0-596-00048-0
Pages
: 936
Slots
: 1
This fourth edition of the definitive reference to
JavaScript, a scripting language that can be embedded
directly in web pages, covers the latest version of the
language, JavaScript 1.5, as supported by Netscape 6 and
Internet Explorer 6. The book also provides complete
coverage of the W3C DOM standard (Level 1 and Level 2),
while retaining material on the legacy Level 0 DOM for
backward compatibility.