I have seen several javascript libraries using $ be it jQuery , mootools , prototype etc also even some of the books on javascript recommend using $ as a function replacement of document.getElementById. is it just a random thing.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The reason $ was actually introduced as a valid variable name in the ECMA specs was to distinguish machine generated code from human written code .
Most JS libraries use $ because it is very rare that you would want to name some of your variable $ and hence it would avoid collision and accidental overwriting of the variable .
( However now since every library is using $ , if you want to use two libraries , you are in a soup ) .