Reflect.getOwnPropertySymbols?

Jason Orendorff jason.orendorff at gmail.com
Mon Mar 16 18:15:09 UTC 2015


On Mon, Mar 16, 2015 at 11:53 AM, Allen Wirfs-Brock
<allen at wirfs-brock.com> wrote:
> In ES6, the primary role of the Reflect object is to provide direct access
> to an object's essential internal methods:
> http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-internal-methods-and-internal-slots

To further elaborate on this: one way this is useful is that the 14
essential internal methods are exactly the operations you can trap
with a custom Proxy. It's useful, when writing a Proxy, to use the
Reflect methods as fallbacks:

    var alertingProxy = new Proxy(obj, {
        // Proxy: hook into property assignment
        set(t, key, value, receiver) {
            alert(`setting the ${key} property of ${t} to ${value}`);

            // Reflect: do normal property assignment
            return Reflect.set(t, key, value, receiver);
        }
    });

-j


More information about the es-discuss mailing list