diff --git a/doc/api/console.md b/doc/api/console.md index 98a05d004f57c5..70b452bd84070f 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -135,15 +135,20 @@ the default behavior of `console` in Node.js. // Creates a simple extension of console with a // new impl for assert without monkey-patching. -const myConsole = Object.setPrototypeOf({ - assert(assertion, message, ...args) { - try { - console.assert(assertion, message, ...args); - } catch (err) { - console.error(err.stack); - } - } -}, console); +const myConsole = Object.create(console, { + assert: { + value: function assert(assertion, message, ...args) { + try { + console.assert(assertion, message, ...args); + } catch (err) { + console.error(err.stack); + } + }, + configurable: true, + enumerable: true, + writable: true, + }, +}); module.exports = myConsole; ```