Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
James Koppenal
Courses Plus Student 9,285 PointsWhy use a $ in the variable as oppose to using without it? Any difference? And what is the best practice?
var $select = $("<select></select>");
$("#menu").append($select);
OR
var select = $("<select></select>");
$("#menu").append(select);
2 Answers

Jacob Mishkin
23,117 PointsA $, is an alias for jQuery. Some people prefer to put a dollar sign together with the variable to make a distinction between regular vars and jQuery objects.

Zachary Billingsley
6,187 PointsHello!
Typically you don't see symbols at the beginning of javascript variables. While it does still work, I would advise against it. If you are mixing javascript and php code, the variables may look similar and get confusing (since php variables are denoted by a "$"). $ is also used in most jQuery code, like you have above, so it is an easy indication of when you are using jQuery instead of plain javascript.
Hope that helps!

James Koppenal
Courses Plus Student 9,285 PointsYes it does help. Thank you!
James Koppenal
Courses Plus Student 9,285 PointsJames Koppenal
Courses Plus Student 9,285 PointsThank you! Jacob.