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 JS: 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

Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS in Depth
  4. JS Reference
  5. DOM
  6. SVG
  7. Web Dev Blog