From aabaef0aa7cc4cc80922c248d2388a8295b31e45 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sun, 25 Dec 2016 20:04:45 +0200 Subject: [PATCH] doc: more efficient example in the console.md Object.setPrototypeOf() -> Object.create() PR-URL: https://github.com/nodejs/node/pull/10451 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- doc/api/console.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) 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; ```