Naming variables

Naming variables

This is not a question, but a point worth emphasising.

When naming variables I often see people using names such as 'url', 'width' and function names such as 'hide()', etc.

I would encourage people to avoid this practice! Although they are not necessarily reserved words or invalid names, they can cause very hard to find errors. In particular, they may work well in one browser, but cause strange effects in another browser. In particular, if you name a function, for example, 'hide()' it is possible that you will hide or overwrite the jQuery hide() method.

For example, someone couldn't discover the cause of a problem in IE (as usual). The problem was that they were using a variable name 'class'. IE didn't offer any sensible error message, and the only way I discovered the problem was by noting that the word was in a slightly different colour within my editor.

Andy.