From 3e4dc60fae7af0cf00c28cc31f3bfdbf58f500e5 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 98a05d004f5..70b452bd840 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; ```