JavaScript: Dollar Sign in JavaScript

By Xah Lee. Date: . Last updated: .

Many JavaScript library use dollar sign $ as the name of their primary function.

The dollar sign is allowed character of identifier. [see Allowed Characters in Identifier]

This practice seems to have started with the Prototype JavaScript Framework, then other libraries picked it up, in particular jQuery. [see jQuery Tutorial by Example]

JavaScript spec ECMA-262 3.0 suggests that the dollar sign should be used for generated code:

The dollar sign ($) and the underscore (_) are permitted anywhere in an identifier. The dollar sign is intended for use only in mechanically generated code.

However, later edition, ECMA-262 5.1 no longer says that.

This standard specifies specific character additions: The dollar sign ($) and the underscore (_) are permitted anywhere in an IdentifierName.

ECMAScript 5.1 §7#sec-7.6

JS in Depth
XAH  BUY NOW