diff options
author | iandrc <hao8@protonmail.com> | 2020-07-24 01:58:35 +0300 |
---|---|---|
committer | himself65 <himself65@outlook.com> | 2020-07-28 18:40:43 +0300 |
commit | 4cee226eb41f2c2e3c71800facc0cbaa2f06ecb5 (patch) | |
tree | 6ce45cc847c47b8c4c5f3779175e437cab45e229 /doc/api/console.md | |
parent | 8598ab8976c0a6ace6eea0857aa093c0e95c6eec (diff) |
console: document the behavior of console.assert()
Add a description and an example of console.assert() call with
no arguments. If called like this, the method should output:
"Assertion failed".
Fixes: https://github.com/nodejs/node/issues/34500
Refs: https://nodejs.org/dist/latest-v14.x/docs/api/console.html#console_console_assert_value_message
Refs: https://console.spec.whatwg.org/#assert
PR-URL: https://github.com/nodejs/node/pull/34501
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Diffstat (limited to 'doc/api/console.md')
-rw-r--r-- | doc/api/console.md | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/doc/api/console.md b/doc/api/console.md index db9b3955a56..a50d09aae87 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -153,6 +153,7 @@ changes: * `...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. @@ -162,6 +163,8 @@ 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` |