handler.ownKeys()
The handler.ownKeys() method is a trap for
Reflect.ownKeys().
Syntax
new Proxy(target, {
ownKeys(target) {
}
});
Parameters
The following parameter is passed to the ownKeys() method.
this is bound to the handler.
target- : The target object.
Return value
The ownKeys() method must return an enumerable object.
Description
The handler.ownKeys() method is a trap for
Reflect.ownKeys().
Interceptions
This trap can intercept these operations:
Or any other operation that invokes the [[OwnPropertyKeys]] internal method.
Invariants
If the following invariants are violated, the trap throws a TypeError when invoked.
- The result of
ownKeys()must be an array. - The type of each array element is either a
Stringor aSymbol. - The result List must contain the keys of all non-configurable own properties of the target object.
- If the target object is not extensible, then the result List must contain all the keys of the own properties of the target object and no other values.