Javascript: August 2008 Archives

Over the past few days, I’ve come across a couple of interesting JavaScript topics that others might find useful. For those of you not interested in all the gory details, I will give you the short list:

  1. In JavaScript function calls, the “this” variable points to whatever class/function called the current function. Even if your function belongs to a class, the “this” variable will point to outside of the class if that function is called directly from somewhere else.

  2. To my knowledge, there is no way to directly access members of a parent class in JavaScript. You have to pass a reference to the parent class to whatever child classes it creates.

  3. In JavaScript you can access any member of an object with array notation (document.formname[“elementName”] for example). This is very useful for referencing parts of objects when you don’t necessarily know what they will be called.

Okay, with that out of the way, those of you interested in all the details can feel free to read on.