When you rely on hacks to get your code to work it is likely that there is also a security exploit that uses the same hacks.In addition, as hacks get fixed in browsers, your code will cease to work in the next version of the browser.
Hungarian notation is a good variable naming scheme to adopt (there are other naming schemes to consider), the advantage being that you know what something is supposed to be and not just what it is. It is very informative for some, but seems like extra overhead to others — it is really up to you whether you use it or not. Programming languages are in English, so why not keep this as a logical step for the rest of your code.
There’s been numerous battles raging over the years about whether to use comments at all, the main argument being that good code should explain itself.
What I see as a flaw in this argument is that explanations are a very subjective thing — you cannot expect every developer to understand what some code is doing from exactly the same explanation. We’ll come back to that in the last point of this article, but let’s say that if your comments end up in the code that end users see then something is not going right. Comment when there is an important thing to say, and if you do comment use the can be problematic if people minify your code without stripping comments and in general are less versatile.
People have been writing extensions for editors (for example the JS Tools for Text Mate) that automatically lint your code when you save it.
JSLint can be a bit touchy about the results it returns and — as its developer Douglas Crockford says — it can hurt your feelings.
Take the advice below to heart and keep it in a part of your brain that has a quick access route so you can apply it without thinking about it.
I am sure you will find things to disagree with, and that is a good thing - you should question what you read, and strive to find better solutions.Try reading Dostojewski if you want a comparison to the real world — I got lost on a page with 14 Russian names, 4 of which were pseudonyms.Don't write code like that — it might make it more art than product, but this is rarely a good thing.I found myself write much better code however, since I installed the Text Mate JS bundle and started subjecting my code to JSLint scrutiny.Clean and valid code means less confusing bugs to fix, easier handover to other developers and better code security.Valid code also means that it can be converted by scripts to other formats — hacky code will need a human to do that.