-2

The $ sign is used by several libraries (jQuery, MooTools, Prototype).

Let say I have a Class called ProjectServices and wouldlike to create an alias like

var #PS = ProjectServices;

Wy is it not allowed to use # as alias or identifier in Javascript ?

Merlin
  • 4,907
  • 2
  • 33
  • 51

2 Answers2

4

It's simply not allowed by basic JavaScript syntax, while $ is. Every programming language defines a syntax allowable for various kinds of symbols.

Pointy
  • 405,095
  • 59
  • 585
  • 614
1

A JavaScript identifier must start with a letter, underscore (_), or dollar sign ($); subsequent characters can also be digits (0-9). Because JavaScript is case sensitive, letters include the characters "A" through "Z" (uppercase) and the characters "a" through "z" (lowercase).

Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Values,_variables,_and_literals

zxqx
  • 5,115
  • 2
  • 20
  • 28