subscribe to RSS

Culturally Sensitive JavaScript

Posted Thursday, March 20, 2008  

JavaScript is a fantastic little language and with the likes of Prototype, Scriptaculous, and my newest favourite, lowpro, you can build some quite frankly, remarkable web applications.

One area where most web browsers fall down however is in their error-reporting, or lack thereof. A fact that has caused me to waste seemingly countless hours trying to find the source of some problem or other only to realise that a typo that had been staring me in the face the entire time was to blame!

Now, like just about any programming library I use these days, most JavaScript libraries use American english. initiali**z**e, capitali**z**e, you know what I’m talking about.

For the most part the use of ‘z’ instead of ‘s’ isn’t too much of a problem but just recently I consistently tried to use lowpro’s addBehaviour method, only there isn’t one. It’s called addBehavior (sans ‘u’).

So today after about 20 minutes cursing and swearing at the spelling Steve asked “is there anyway you could create an alias?” Being JavaScript the answer is of course “abso-bloody-lutely!”:

Event.addBehaviour = Event.addBehavior;

You can alias just about anything this way.

No more will my code silently fail due to differences in spelling :)

Tweet This Delicious Reddit Stumble Upon Digg Share on Tumblr email

About Simon

Husband, Father, One-time Entrepreneur.

Aka Haruki Zaemon. Aka Sampy.

In my younger years I wanted to save the world; now I'm happy solving bigger problems than I create.

If I didn't need to work I'd be teaching Aikido and spending all my free time with my amazing wife and two children in Woodend, Victoria, Australia.

Books

Beginning Algorithms
with James Ross

Software

Simian
Similarity Analyser

Blog Categories