Pages

Monday, September 19, 2016

Identifiers and Keywords (and Literals, O My!)

Identifiers are programmer-defined names (for entities).

In JavaScript names like box, thing1 and thing2 are examples of JavaScript identifiers. A JavaScript identifier must begin with an underscore (_), a dollar sign ($) or a letter and may be followed by underscores, dollar signs, letters, digits or any combination thereof.

In Java names like box, thing1 and thing2 are examples of Java identifiers. Java identifiers must start with a letter and may be followed by letters, digits, or both.

Letters and digits used in JavaScript or Java identifiers may come from the entire Unicode character set.



Keywords are language-defined names that are reserved and cannot be used as identifiers because they have special meaning in the context of a programming language. Keywords in a particular programming language are often a subset of the language's reserved words.

In JavaScript the word function is an example of a JavaScript keyword. As of ECMAScript 6 (a name for a particular JavaScript specification) there are thirty-three keywords in JavaScript. In addition to these thirty-three keywords there are some words, like the word enum, that have no special functionality in ECMAScript 6 but might have special meaning in the future specifications of the JavaScript language and therefore cannot be used as identifiers.

In Java the words abstract, double, int and byte are among fifty keywords in Java. The words null, true and false are similar to Java keywords but are technically called literals, as are numbers like 42. Literals, like keywords, cannot be used as identifiers.