We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example
const a = new Proxy({ i: 1 }, { get: (target) => () => target.i++, }) console.log(a == 1, a == 2, a == 3);
Explaination
[Symbol.toPrimitive]
const a = new Proxy({ i: 1 }, { get(target, property) { console.trace("[Proxy] get() called with", { target, property }); return function inner() { console.trace("[Proxy] inner() called"); return target.i++; } } }) console.log(a == 1, a == 2, a == 3);
Log
[Proxy] get() called with { target: { i: 1 }, property: Symbol(Symbol.toPrimitve) } [Proxy] inner() called ...
Basically, object is equal to
const a = { i: 1, [Symbol.toPrimitive]() { return this.i++; } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Example
Explaination
[Symbol.toPrimitive]
is accessedLog
Basically, object is equal to
The text was updated successfully, but these errors were encountered: