Skip to content

Fix Proxy examples#91

Open
leobalter wants to merge 1 commit intolukehoban:masterfrom
leobalter:patch-1
Open

Fix Proxy examples#91
leobalter wants to merge 1 commit intolukehoban:masterfrom
leobalter:patch-1

Conversation

@leobalter
Copy link
Copy Markdown

the [[Get]] internal slot of Proxy calls the handler with target, P, and receiver as arguments.

the [[Call]] internal slot [calls the handler] with thisArgument and an argsList which is an Array made from the argumentsList. You don't need to use a rest parameter there.

the [[Get]] internal slot of Proxy [calls the handler](http://www.ecma-international.org/ecma-262/6.0/index.html#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver) with `target`, `P`, and `receiver` as arguments.

the [[Call]] internal slot [calls the handler] with `thisArgument` and an `argsList` which is an Array made from the argumentsList. You don't need to use a rest parameter there.
Comment thread README.md
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about keeping "name", but change the parameters? Maybe use a different example that clarifies the use of this. For example:

var person = { name: "Alice" };
var handlers = {
    get: function (target, property, receiver) {
        if (property === "realName") {
            return target.name;
        } else if (property === "fakeName") {
            return "Really " + receiver.name;
        }
        return "Bob";
    }
};

var fakePerson = new Proxy(person, handlers);
fakePerson.name === "Bob" &&
fakePerson.realName === "Alice" &&
fakePerson.fakeName === "Really Bob";

@objectivezhou
Copy link
Copy Markdown

objectivezhou commented Jun 14, 2024 via email

@weinianhuan
Copy link
Copy Markdown

weinianhuan commented Jun 14, 2024 via email

@MehdiRaash
Copy link
Copy Markdown

LGTM

@weinianhuan
Copy link
Copy Markdown

weinianhuan commented Aug 9, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants