Skip to main content. Skip to secondary content (sidebar).

Posts Tagged ‘oop’

Emulating classical inheritance in JavaScript destroys the purity of the language

I wish I could say that was an exaggeration, but after a lot of thought, I believe that is the current state of the language. Some might consider it progress to push JavaScript that much closer to a pure object-oriented (OO) language, but I think it continues to bring with it false expectations. There are too many other limitations (which is not necessarily a bad thing), and a classical inheritance structure only serves to confuse beginners who are unable to learn JavaScript responsibly.

Continue Reading »

Pass parameters to your JavaScript functions correctly from setTimeout() using OOP

08/11/08 Update:
This post was revisited with a more intuitive example.
Please visit Pass arguments through to your JavaScript functions from setTimeout() (revisited)

If you are moving beyond using JavaScript for simple tasks, and are building full fledged Web applications, then you will likely make heavy use of the setTimeout() method available to the window object. This timer can be powerful, but it also possesses a single shortcoming that stumps even experienced programmers. There is no “built-in” mechanism within setTimeout() for calling a function that needs parameters passed to it.

Continue Reading »