I've just seen some dude suggest the following syntax instead of the one I'm usually (always) using.
$newToMe = "I haven't used this way";
var oldWay = "I've always use this way";
$myCoolStuff.thing1 = $(".ones");
$myCoolStuff.thing2 = $(".twos");
In terms of "jQuery scope pollutions", the two alternatives are the same. $me
is just one of (of many) conventions as to how to name a variable - this one being related to distinguishing jQuery objects from regular ones.
However, worth mentioning is that (given the code above) $newToMe
will be added to the global scope (and found in window
) where-as oldWay
won't. Why? Well, the var
keyword will cause it to be restricted to its current context.