self– I see this a lot when setting a pointer to the
thisobject, such as:
var self = this;. Oftentimes, this is how developers are keeping a reference to an object for use inside of a closure. The problem is that
selfis already in use as another pointer to the
windowobject. Don’t redefine
selfas something other than what it is as it could confuse others looking at your code. (proof)
top– This one is most often used in combination with a variable named
leftto determine or set element coordinates. Once again, the problem is that
topis a host object, it points to the outermost
windowobject and is most useful when used from within a frame. (proof)
location– I’m surprised, but I have seen variables with this name. This is a host object containing information about the page that is currently loaded. (proof)
Again, these are variables names that should never be used. When people expect variables with particular names to behave a certain way, it’s always dangerous to change their behavior. You might as well just start redefining methods on the
Disclaimer: Any viewpoints and opinions expressed in this article are those of Nicholas C. Zakas and do not, in any way, reflect those of my employer, my colleagues, Wrox Publishing, O'Reilly Publishing, or anyone else. I speak only for myself, not for them.
Both comments and pings are currently closed.