7

I want a variable like $ that is sort of special, but I'm already using jQuery, so $ is taken.

1
  • You could always run JQuery in compatibility mode and type in jQuery instead of $. Commented Jul 18, 2009 at 3:56

5 Answers 5

6

Unfortunately, older javascript supports letters, numbers, underscores, and $ in identifiers. In javascript 1.5 and later you can use Unicode characters, but that would be a very bad idea as they can be a pain to enter into most editors, and certainly aren't something you would want to have to type very often.

Source

Sign up to request clarification or add additional context in comments.

1 Comment

That's the source I was looking at. :-)
5

The one I like it best:

λ = Function;

Unfortunately it's very difficult to type it.

Comments

2

If you want a special variable like $ but $ is already taken by jQuery, why not use something that starts with $, like $a or similar? Just make sure it's one that jQuery doesn't also define.

1 Comment

jQuery can handle $ conflicts, so $ could be just fine. After all, jQuery borrowed the dollar from prototype.js
2

Underscore is the only one I can think of. You can put a few together like _$_.

Starting in JavaScript 1.5, you can use Unicode such as å.

Comments

1

Prototype uses $ and a $$. If you're using jQuery, you could use $$. However, unless its really well documented, this may be a bad idea--especially if someone else has to maintain this code after you've moved on.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.