• {symbol} that can be used to declare custom inspect functions.

    In addition to being accessible through util.inspect.custom, this symbol is [registered globally][global symbol registry] and can be accessed in any environment as Symbol.for('nodejs.util.inspect.custom').

    1. const inspect = Symbol.for('nodejs.util.inspect.custom');
    2. class Password {
    3. constructor(value) {
    4. this.value = value;
    5. }
    6. toString() {
    7. return 'xxxxxxxx';
    8. }
    9. [inspect]() {
    10. return `Password <${this.toString()}>`;
    11. }
    12. }
    13. const password = new Password('r0sebud');
    14. console.log(password);
    15. // Prints Password <xxxxxxxx>

    See [Custom inspection functions on Objects][] for more details.