JS: 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 1999 suggests that the dollar sign should be used for generated code:

js ECMA-262 3 1999
ECMA-262, 3rd edition, December 1999
“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, JavaScript spec year 2011, 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

BUY ΣJS JavaScript in Depth