Thursday, June 1st, 2006

What to do with Objects, Arrays, and Libraries that Use Them

Category: JavaScript

It’s official, at least according to James McParlane: June 6 is “Array” and “Object.prototype” Awareness Day.

I want my children to grow up in a world when coding in JavaScript does not result in a fistfight … Brendan Eich may have intended Arrays to be only numeric, but the reality is they do more, and people have explored and used them to the fullest extent.

He proposes the following ground rules for happy co-existence – see his article for the details on each of these.

  • Don’t use Object.prototype to extend the base ‘Object’.
  • Don’t use ‘Array’ for an Associative Array
  • There are two types of Library ‘Primary’ or ‘Secondary’. James sees Dojo, Prototype, et al becoming “primary” libraries on which other, more specialized libraries, build.
  • Port code that uses ‘Array’ for Associative Arrays. (Use objects and not Arrays for associative array behavior.)
  • Write JavaScript Tools That Warn Of Rule Violations.

Posted by Michael Mahemoff at 10:59 am

4 rating from 26 votes


Comments feed TrackBack URI

Michael, just pointing out that the “see his article” link points to your article.

Comment by Olivier Ansaldi — June 1, 2006

Fixed that, thanks Oliver.

Comment by Michael Mahemoff — June 1, 2006

Leave a comment

You must be logged in to post a comment.