Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

JavaScript | handler.ownKeys() Method

  • Last Updated : 28 Sep, 2021

The handler.ownKeys() method in JavaScript is a trap for Reflect.ownKeys() method and this method returns an enumerable object.

const p = new Proxy(target, {
  ownKeys: function(target) {

Parameters: This method accepts a single parameter as mentioned above and described below: 

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

  • target: This parameter holds the target object.

Return value: This method always return an enumerable object.
Below examples illustrate the handler.ownKeys() method in JavaScript:
Example 1: 


const monster1 = {
  prop1: 253,
  prop2: "Geeks",
  prop3: 0101011
const handler1 = {
  ownKeys (target) {
    return Reflect.ownKeys(target)
const proxy = new Proxy(monster1, handler1);
for (let key of Object.keys(proxy)) {



Example 2: 


var proxy1 = new Proxy({}, { 
  ownKeys: function(target) { 
   document.writeln(" <br> handler.ownKeys() Method <br> <br>"); 
    return ['Geeks1', 'Geeks2', 'Geeks3']; 


handler.ownKeys() Method


Supported Browsers: The browsers supported by handler.ownKeys() method are listed below: 

  • Google Chrome 49 and above
  • Edge 12 and above
  • Firefox 18 and above
  • Opera 36 and above
  • Safari 10 and above


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!