"Subclassing" basic types in DOM - best method?

Tab Atkins Jr. jackalmage at gmail.com
Tue Nov 20 14:56:52 PST 2012


On Tue, Nov 20, 2012 at 2:52 PM, Rick Waldron <waldron.rick at gmail.com> wrote:
> On Tuesday, November 20, 2012 at 5:23 PM, Tab Atkins Jr. wrote:
>> function foo() {...}
>> foo.prototype = [];
>
> var a = new foo();
> a.push(1);
>
> a.length; // 1
> a.length = 0;
>
> console.log(a);
>
> {"0":1,"length":0}
>
> Again, it's not possible to subclass Array.

Ah, true.  Then again, I've only ever seen that use of .length here on
this list.  I'm sure it exists, but it doesn't in my head.  ^_^

~TJ


More information about the es-discuss mailing list