Possible Duplicate:
Why would a JavaScript variable start with a dollar sign?
I realized some syntax with jquery and didnt know what it is. here goes:
var $foo = $("bar").blah();
var hello$ = $("stgelse").etc();
What is the difference between these? and why are they like that?
Also, For example:
var $foo = $("").blah();
var should already contain whatever right side is returning ? no?
Can you please elaborate?
varis a keyword that makes the variable local in certain cases. See this question$foois the name of this variable. There is no need for the$, and indeed it confuses everything, but some languages (like PHP) need them to say “this is a variable”. It could’ve been justfoo=is the assignment to make$foohave whatever comes from the right hand side$is another variable, but a special one: this is your JQuery thingy! From there you see it does all the JQuery stuff, like “findbar, doblah()etc.The same basically goes for the other line, but in this case someone thought that
hello$would be a nice name for a var 🙂