Standardizing __proto__

John-David Dalton john.david.dalton at gmail.com
Fri Mar 18 13:53:53 PDT 2011


> I think I understand what you doing here, especially for Array but I don't think it really addresses my  Number, Boolean, String question.
> Instances of those instances usually aren't created via explicit constructor calls but by implicit conversions that the ES5 spec. "hardwires"
> to the appropriate built-in prototype object. In the most common cases for es5, say "string".concat(foo) a string object isn't even created for the property lookup.
>
> I'm skeptical that many developers actually   would code: fs.String("stirng").concat(foo) rather than"string".concat(foo).  How much actual usage do you see of the Number, Boolean, and String cases?

Ya, some people have that reaction at first, but after use it's not
bad. Most of the time you create a string or value once then pass
around the variable.
Because these sandboxed natives chain, usage is natural. As such
fuse.String(...).split(' ') produces a sandboxed Array so you go from
1 sandboxed native to another without hassle.
Same goes for fuse.Array(1,2,3).join() -> a sandboxed String value.

Generics are also supported fuse.String.concat(str, other) so you can
pass in regular natives too.

PrototypeJS and other libs use wrapper/utilities for strings, DOM
elements, arrays, ... so using fuse.String() is just as easy as say
$w().
By using the framework it becomes second nature to assume, for
example, fuse(...).getAttribute(..) returns a sandboxed String value.

-JDD


More information about the es-discuss mailing list