Skip to content

Commit 465968c

Browse files
iandrccodebytere
iandrc
authored andcommitted
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: #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: #34501 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Anto Aravinth <[email protected]> Reviewed-By: Zeyu Yang <[email protected]>
1 parent f46649b commit 465968c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

doc/api/console.md

+3
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ changes:
151151
* `...message` {any} All arguments besides `value` are used as error message.
152152

153153
A simple assertion test that verifies whether `value` is truthy. If it is not,
154+
or `value` is not passed,
154155
`Assertion failed` is logged. If provided, the error `message` is formatted
155156
using [`util.format()`][] by passing along all message arguments. The output is
156157
used as the error message.
@@ -160,6 +161,8 @@ console.assert(true, 'does nothing');
160161
// OK
161162
console.assert(false, 'Whoops %s work', 'didn\'t');
162163
// Assertion failed: Whoops didn't work
164+
console.assert();
165+
// Assertion failed
163166
```
164167

165168
Calling `console.assert()` with a falsy assertion will only cause the `message`

0 commit comments

Comments
 (0)