-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,847
  • 2
  • 30
  • 47

2 Answers2

3

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

Pointy
  • 389,373
  • 58
  • 564
  • 602
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
  • 4,990
  • 2
  • 19
  • 28