[Project_owners] Defining new array methods (SeaMonkey vsFirefox).

Nickolay Ponomarev asqueella at gmail.com
Fri Jun 23 19:46:13 EDT 2006


On 6/23/06, Peter B. Shalimoff <vshalim at home.ru> wrote:
> it's better to define substr() method once - in
> Object.prototype:
>
> Object.prototype.substr = function(){return "...";};
>
> Now every object will have substr() method,

No, actually it's better to avoid modifying Array.prototype or
Object.prototype altogether those objects are shared with other
scripts. Exactly because of this problem - someone will try to use the
for..in loop to cycle through array's items or object's own
properties.

Nickolay


More information about the Project_owners mailing list