The class operator: a bridge between object and function exemplers
Allen Wirfs-Brock
allen at wirfs-brock.com
Mon Nov 14 18:21:23 PST 2011
I think you're on the write track of the fix here. I knew I needed to specify something similar to make instanceof work reasonably for object exemplars. I need to look at it a bit more to be sure.
Allen
On Nov 14, 2011, at 5:18 PM, Mark S. Miller wrote:
> On Mon, Nov 14, 2011 at 5:13 PM, Mark S. Miller <erights at google.com> wrote:
>
> function [[GetClass]](x) {
> while (true) {
> const proto = Object.getPrototypeOf(x);
> if (proto === null) { return null; /* or void 0? */ }
> let result;
> if (hasOwnProperty(proto, 'constructor') &&
> (result = proto.constructor) &&
> typeof result === 'function' &&
> result.prototype === proto) {
> return result;
> }
> }
> }
>
> Oops. Should be
>
> function [[GetClass]](x) {
> while (true) {
> x = Object.getPrototypeOf(x);
> if (x === null) { return null; /* or void 0? */ }
> let result;
> if (hasOwnProperty(x, 'constructor') &&
> (result = x.constructor) &&
> typeof result === 'function' &&
> result.prototype === x) {
> return result;
> }
> }
> }
>
> --
> Cheers,
> --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111114/077f00fd/attachment.html>
More information about the es-discuss
mailing list