Hide object keys when console.log-ging in JavaScript

When doing a console.log on an object, you can overwrite the inspect prototype key to hide anything you don’t want users of the code to see.

Custom.prototype.inspect = function (depth, opts) {
    return 'foo = ' + this.foo.toUpperCase();
};

keywords: log, javascript, hide, hiding, inspect

This article was updated on 2023-01-25

I'm nabeards. I'm a full stack JavaScript developer. I travel full time, a.k.a., Professional Wanderer, a.k.a., Digital Nomad.