Which characters can be used for naming a JavaScript variable?
I want to create a small \"extension library\" for my non-JavaScript users here at work (who all seem
Javascript Variables
You can start a variable with any letter, $
, or _
character. As long as it doesn't start with a number, you can include numbers as well.
Start: [a-z], $, _
Contain: [a-z], [0-9], $, _
jQuery
You can use _
for your library so that it will stand side-by-side with jQuery. However, there is a configuration you can set so that jQuery will not use $
. It will instead use jQuery
. To do this, simply set:
jQuery.noConflict();
This page explains how to do this.