On May 31, 7:41 am, Sapna Grover <[EMAIL PROTECTED]> wrote:
> It is clear now Thx

While using an Array like a plain Object is considered bad coding
style in general, there is nothing wrong with it in terms of syntax -
it doesn't break any part of the ECMAScript specification - and there
are situations where it can be considered the right thing to do.

It is also considered wrong to use $ for variable names in human
generated code, yet Prototype.js has no problem with that.  It's also
considered bad to extend built-in objects (like Array, String, etc.) -
again, Prototype.js has no problem with that either.  Up to version
1.5 it extended Object, fortunately the authors saw fit to fix it.

A simple solution is don't use Prototype.js, but I suspect that's not
the answer you're looking for.  :-)  Another is to modify
Prototype.js's $A object so that $A is extended, not the built-in
Array object.  That way you can still get a plain Array when you want
and wherever you want a Prototype extended array, intiialise it with:

  var plainArray = [];
  var extendedArray = new $A();

or maybe

  var extendedArray = $A();

or similar.  Other libraries seem to be able to do it without any
issues so I suspect Prototype.js can too quite easily.


--
Rob


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to