$ at the beginning and at the end of variable

javascript, jquery

Solution

var $foo = $("bar").blah();

- `var` is a keyword that makes the variable local in certain cases. See this question

- `$foo` is 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 just `foo`

- `=` is the assignment to make `$foo` have 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 "find `bar`, do `blah()` 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 :)

Problem

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?

Original source

Related problems