Why we need to clean up __proto__

Mark S. Miller erights at google.com
Wed Dec 28 17:52:43 PST 2011


Actually, there's no reason for the prefix or suffix to be random or
unguessable or whatever.
http://code.google.com/p/es-lab/source/browse/trunk/src/ses/StringMap.jssimply
uses "$" as a suffix.

As for the performance issues of prefix or suffixing, I haven't measured.
But performance measurements are only relevant when comparing different
means of being correct. As (I think) Gerald Weinberg once said "If the
program doesn't need to be correct, I can make it arbitrarily fast."


On Wed, Dec 28, 2011 at 8:39 AM, John-David Dalton <
john.david.dalton at gmail.com> wrote:

> The cross-browser differences of {}.hasOwnProperty('__proto__') and
> {}.__proto__.hasOwnProperty('__proto__') are interesting and need to
> be ironed out.
>
> As for the issue of using objects as dictionaries you can simply
> prefix keys with some unique value, `var uid = 'uid' + (+new Date);`,
> and then access entries like `dict[uid + key]`. This will allow value
> lookups to work correctly cross-browser regardless of ES5+ or
> __proto__ support.
>
> - JDD
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111228/925c2ceb/attachment.html>


More information about the es-discuss mailing list