How to prettify output of objects in the console, when using get/set, like browsers do?

dante federici c.dante.federici at gmail.com
Thu Jan 10 14:08:39 UTC 2019


So, it actually all works as you'd expect when using properties on the
class itself:

```js
```

In that polyfilll, it actually is making x, y, z, and w private fields:
https://github.com/trusktr/geometry-interfaces/blob/41d8cca9c0b4e4ab7afbb9a3a1d02ca94d048f3f/src/DOMPoint.js#L2
```js
const _ = o => {
    if (!privatesMap) {
        privatesMap = new WeakMap
        let privates = {}
        privatesMap.set(o, privates)
        return privates
    }
    else {
        let privates = privatesMap.get(o)

        if (privates === undefined) {
            privates = {}
            privatesMap.set(o, privates)
        }

        return privates
    }
```


So, the new instances _never_ have a visible property for the console to
display. Compare to:

```js
class Test {
    constructor(x) { this._x = x }
    get x(){ return this._x; }
    set x(v){ this._x = v; return v; }
}
console.log(new Test(123));
> Test { x: 123 }
```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190110/6f269372/attachment.html>


More information about the es-discuss mailing list