1

How to check If argument is a Proxy exotic object, then check If argument.[[ProxyHandler]] is null ?

Vigen
  • 13
  • 2
  • You don't, that's the idea of proxies: they are not distinguishable from normal objects. – Bergi Mar 26 '19 at 07:20
  • 1
    Why do you need this? What is your [actual problem](https://meta.stackexchange.com/q/66377) that you are trying to solve? – Bergi Mar 26 '19 at 07:21
  • I want to check argument via this function 1. If Type(argument) is not Object, return false. 2. If argument is an Array exotic object, return true. 3. If argument is a Proxy exotic object, then a. If argument.[[ProxyHandler]] is null, throw a TypeError exception. b. Let target be argument.[[ProxyTarget]]. c. Return ? IsArray(target). 4. Return false. – Vigen Mar 26 '19 at 07:23
  • What is "this function"? Sounds like you quoted a part of the spec. – Bergi Mar 26 '19 at 07:24
  • I want to understand ECMA 262 standard end learn how to convert it into javascript code – Vigen Mar 26 '19 at 07:26
  • This is indeed the [ES2018 isArray specs](https://tc39.github.io/ecma262/#sec-isarray). But this is meant to define a JS built-in, you are like trying to make something define itself. For instance, point **2** is only doable from the js-engine itself. We have no other way from js to know if an Object is an Array than using this very `isArray` method. – Kaiido Mar 26 '19 at 07:27
  • @Vigen You can't convert all native methods into javascript code, that's why they are native. – Bergi Mar 26 '19 at 07:29
  • @Kaiido, yes, you are right, but 10 years ago there wasn't isArray method, how it was checked? – Vigen Mar 26 '19 at 07:30
  • A calculator cannot calculate the state of any part of it's internal circuit even thought the calculator itself is a collection of low level logical gates. A machine might not be able to access itself at a level which is more close to the bare metal it is built with. – Charlie Mar 26 '19 at 07:36
  • @Vigen that was hard: https://stackoverflow.com/a/2265999/3702797 That's why it's been implemented ;-) But at that time, there was no Object.defineProperty nor Object.create, so forwhat that mattered, an object that looked like an Array and acted like an Array and said it was an Array was an Array. – Kaiido Mar 26 '19 at 07:52

0 Answers0