Chapter 3. Language Basics

At the core of any language is a description of how it should work at the most basic level. This description typically defines syntax, operators, data types, and built-in functionality upon which complex solutions can be built. As previously mentioned, ECMA-262 defines all of this information for JavaScript in the form of a pseudolanguage called ECMAScript (often pronounced as "ek-ma-script").

ECMAScript as defined in ECMA-262, Third Edition, is the most-implemented version among web browsers. The Fourth Edition introduced new syntax, operators, objects, and concepts that dramatically alter how JavaScript works. For this reason, and due to a lack of support, the following information is based only on ECMAScript as defined in the Third Edition (see Chapter 22 for information on the Fourth Edition and JavaScript 2.0).

Syntax

ECMAScript's syntax borrows heavily from C and other C-like languages such as Java and Perl. Developers familiar with such languages should have an easy time picking up the somewhat looser syntax of ECMAScript.

Case-sensitivity

The first concept to understand is that everything is case-sensitive: variables, function names, and operators are all case-sensitive, meaning that a variable named test is different from a variable named Test. Similarly, typeof can't be the name of a function because it's a keyword (described in the next section); however, typeOf is a perfectly valid function name.

Identifiers

An identifier is the name of a variable, ...

Get Professional, JavaScript® for Web Developers, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.