there is no difference between var $test
and var test
. but its always good to know what kind of data is in your variable: (for example if someone else just want to modify a function in your code without having to read, or have to console.log your vars to know whats in it)
here some examples:
var arrTest = [1, 2, a, b, c], //Array
objTest = {test: 1, test2: 2}, //Object
strTest = "test", //String
intTest = 4, //integer
$test = $("#test") //jqueryObject
but it would also work like this
var Test1 = [1, 2, a, b, c], //Array
test2 = {test: 1, test2: 2}, //Object
Test3 = "test", //String
Test4 = 4, //integer
$test = $("#test") //jquery Object
i think what confuses you is the $()
form jquery.
Jquery is basically a function set on the variable name $
:
var $ = function(e){ // the jquery magic }
but you can still use $somethingelse
as variable.