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. Edited by justsomeguy
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...