From f393ae929628f879aa966f8c84345faa8b4859c5 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 28 Jul 2020 21:42:36 -0700 Subject: [PATCH] doc: simplify and clarify console.assert() documentation PR-URL: https://github.com/nodejs/node/pull/34544 Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Luigi Pinca --- doc/api/console.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/doc/api/console.md b/doc/api/console.md index 3baac4bdac0da8..9e4548581b5f70 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -150,24 +150,23 @@ changes: * `value` {any} The value tested for being truthy. * `...message` {any} All arguments besides `value` are used as error message. -A simple assertion test that verifies whether `value` is truthy. If it is not, -or `value` is not passed, -`Assertion failed` is logged. If provided, the error `message` is formatted -using [`util.format()`][] by passing along all message arguments. The output is -used as the error message. +`console.assert()` writes a message if `value` is [falsy][] or omitted. It only +writes a message and does not otherwise affect execution. The output always +starts with `"Assertion failed"`. If provided, `message` is formatted using +[`util.format()`][]. + +If `value` is [truthy][], nothing happens. ```js console.assert(true, 'does nothing'); -// OK + console.assert(false, 'Whoops %s work', 'didn\'t'); // Assertion failed: Whoops didn't work + console.assert(); // Assertion failed ``` -Calling `console.assert()` with a falsy assertion will only cause the `message` -to be printed to the console without interrupting execution of subsequent code. - ### `console.clear()`