Jump to content

Good Javascript Practices


Guest FirefoxRocks

Recommended Posts

The guy who wrote that for jslint did a good enough job, you don't really need to re-write it with things that might not be true. This statement, for example, is not true:

In the previous example, declare def() before abc() because you will be using it in abc().
You can declare functions in any order and have them all still work. If you don't understand why, then you don't understand Javascript parsing. That's not the reason he said to declare variables before you use them.
Use commas as a separator only
How else would you use a comma?
Maybe it's to save space, maybe it's for some other reason.
It's not to save space. Maybe you can figure out the 'why' before you tell people to do it.
Use the == operator to compare values.
Use === to compare instead of ==
Which is it? What should you do if you know the values are different types?
10. Avoid ++ and --Now this is one that I don't understand. Apparently it is a security issue to use ++ and -- increment operators.
I don't understand why you're telling people to do things, and then saying that you don't understand why you should do those things. I'd also like to see an example where using one of those operators introduces a security problem.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...