> Le 9 mai 2019 à 23:17, Tom Barrasso <[email protected]> a écrit :
>
> If this Symbol were seriously considered I believe it would expand the
> meaning of the in operator as you’re correct, this is definitely not it’s
> current intention.
>
The `in` operator has a well-defined meaning, that by design you can’t ignore
even with the fanciest proxy. (And no, there is no hope for introducing a new
mechanism that allows to overcome those limitations, since they are by design.)
Consider for example the following proxy around a String object:
```js
function conflateInAndIncludes(str) {
return new Proxy(Object(str), {
has(target, key) { return str.includes(key) }
})
}
var FrankensteinFood = conflateInAndIncludes("food");
"foo" in FrankensteinFood // true, yeah!
"bar" in FrankensteinFood // false, yeah!
"length" in FrankensteinFood // TypeError: proxy can't report a
non-configurable own property '"length"' as non-existent
```
—Claude_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss