I am reading a book on jQuery and I've seen in a few code examples in the book where the author will declare variables with a preceding $. My question is simply whether or not the $ is significant in itself or is it simply a convention/tradition to broadcast immediately to anyone who sees the variable that's its a jQuery object and 'not' a regular JavaScript object?

If I declare two variable like this using jQuery: $jQueryvar = $('body'); jQueryvar = $("body");

Is there any difference between the two other than the $ being a part of the identifier. If there is a difference is it even possible to assign a jQuery object to a regular JavaScript object without using the preceding $ character?

I think I've got my question across. It seems difficult to word for some reason but if anyone can help clear this up that would be great. Thanks.

chris_upjohn
—
2012-06-30T03:41:32Z —
#2

Pre-pending a variable with $ basically allows us to see what is a jQuery object and whats a standard JavaScript variable, developers including myself do this now as it makes it a lot faster to debug code that mixes between the jQuery scope and the standard element scope.

Overall there is no difference between the two apart from what they mean to us as developers.

ig_88
—
2012-06-30T23:22:55Z —
#3

chris_upjohn said:

Pre-pending a variable with $ basically allows us to see what is a jQuery object and whats a standard JavaScript variable, developers including myself do this now as it makes it a lot faster to debug code that mixes between the jQuery scope and the standard element scope.

Overall there is no difference between the two apart from what they mean to us as developers.

That was what I was hoping you would say. Every clever idea actually. I like it. No significance to the behavior of the script but instantly recognizable as a jQuery object versus a JavaScript object to anyone who knows. Very cool!!