I can see 3 possible aspects to this question, so I will answer all three:
The $
sign
In JavaScript the $
is just another character which can be used as part of a variable name, and is part of the name. This is unlike PHP, where the $
sign is use as a prefix, and is not part of the name.
Just like any other valid character (except numerals) the $
can be used by itself as a valid name, and jQuery has used this to name their main function (AKA jQuery
).
You can choose to name your variables anything you like, but many developers like to start some with $
sign as a reminder that it represents a jQuery object which is non-trivial object.
In other words, it makes no difference whether you decide to begin with the $
or not, as long as you remember what you’ve done.
Are the 2 variables the same?
Apropos the above, the two variable names are not the same. One has 4 characters, and one has 5. They don’t have any relationship to each other at all.
Are the two objects the same?
Every time you run the jQuery function, you get a new object. This object contains, among other things a reference to the DOM object referred to in your argument.
Even though the two jQuery objects refer to the same DOM object, the objects themselves are not the same.
This is a trap that many new jQuery developers fall in:
$current=$('div#something');
// some stuff
if($current==$('div#something')) …; // always false
There you are. Three answers. Take your pick :)