diff --git a/doc/api/console.md b/doc/api/console.md index 6d75198d019d67..a7d56b4a37a95e 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; ```