Some of the following ideas are my opinion, but I find they're generally good ideas. In general, 'good habits' when programming are things that will potentially make your coworkers hate you less. As a counterpoint, all of the ideas here (and so far, they're ALL excellent ones) are not strictly necessary: you could write un-commented code, where everything is in one file, etc, etc, and your program would work. However, if you then ask your coworker Steve to work on your code, you're going to need to spend an inordinate amount of time teaching Steve what the heck your code does.
In general, here's what I do:
1) Comment your code. There's a bit of a balance here: you don't, for example, want to have the following:
var c = a + b;//adds a and b, stores in c.
because that's pretty obvious. However, let's say you're writing a particle system, and you have a variable "ppLS". You might do the following:
var ppLP=100;//per-particle life 'points', starting at 100.
2) SRP, or Single Responsibility Principal, also known as modularizing your code. Basically, this means separating your code into small bits. This has a number of benefits. Firstly, if you need to replace a bit of code, it's easier to find it. Second, you can have multiple resources pulling from the same file (so, for example, multiple parts of your site could pull from the authentication bits).
3) Name your variables, functions, etc. semantically. It's easy to get lazy and name your variables things like "a", "b" and "myVar", but what happens when you (or your coworkers) come back months later and try to edit the code? Are you going to remember what 'var a' does? Again, a bit of a balance here: don't go off the deep end and name your variable something like "var this_var_stores_the_users_first_name_so_we_can_say_hi", for example.
4) Finally, learn current trends! Learn what's popular, and what people are expecting you to use. Most stuff in coding becomes popular because people are like "Oh, wow, that's a really cool/useful way of doing X!".
EDIT: response:
For point 4, all I mean is you should read lots of current web development blogs and stuff. For example, in 2012, I believe AngularJS was quiet popular. Then eventually, it was followed by ReactJS, and now with the release of AngularJS 2, Angular's becoming more popular. So knowing what libraries, components, etc. are currently in vogue (and, moreover, WHY they are in vogue) will help you take advantage of these new tools.
For point 3, I'm not sure I can give you a specific set of guidelines, but I generally say that my variable names should be no more than two "words" (or two "words" and an abbreviation). For example:
var var1;//bad, no description
var lifeHP;//good, small and tells us what it's about
var particleLifeHitPointsForInvidualParticle;//bad, since the same idea can be represented, semantically, in a far shorter name.