I don't grok the idea/purpose/use of Javascript $, as in
function $(id) { return document.getElementById(id); }
Could someone please explain or point me at an explanation?
Thanks!
-- Pete
There are two main reasons to use $ as a function name, especially in frameworks like jQuery:
$is just a variable name. It can be confusing at first blush since many other languages use '$' to denote a variable... but in the JS case it can be the whole name. Plus function names are also variables which means you can havevar $='hello';orfunction $() {}or evenvar $=function() {};(2nd and 3rd result in the same) helpful primer - Rudu