How different var $firstName or and firstName in jQuery?

When I create var with jquery which is firstName value.

var $firstName = '';


var firstName = '';

How different '$' or not.

Answers 1

  • You can just use both of them as $ in variable name has nothing to do with jquery. As long as you have a valid javascript variable name, you can use $ before your variable name.

    So for example :

    var $firstName = "ABC";


    var firstName = "ABC";

    when called in will output same things :$firstName); // outputs "ABC" in firebug console.; // outputs "ABC" in firebug console.

Related Articles