4

How to hide Target And Handler in console and debug ?

I want to see plain javascript object in console and while debugging.

Code

    const target = {};
    const proxyobject = new Proxy(target, {});

    proxyobject.name = 'tom';
    proxyobject.address = 'earth';

    console.log(proxyobject);

Output - In chrome and firefox console are same as below image

enter image description here

Note

  1. if i do JSON.stringify(proxyobject) it prints json string

  2. in some code editors internal console it prints json

    2.1 jsbin

vijay
  • 10,276
  • 11
  • 64
  • 79

1 Answers1

0

    const target = {};
    const proxyobject = new Proxy(target, {});

    proxyobject.name = 'tom';
    proxyobject.address = 'earth';

var myData; 
var {name,address,myData={name,address},...others} = proxyobject; 
console.log(myData)

We can make use of es6

nivendha
  • 792
  • 7
  • 16