Skip to content

Commit 4cee226

Browse files
iandrchimself65
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 8598ab8 commit 4cee226

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
@@ -153,6 +153,7 @@ changes:
153153
* `...message` {any} All arguments besides `value` are used as error message.
154154

155155
A simple assertion test that verifies whether `value` is truthy. If it is not,
156+
or `value` is not passed,
156157
`Assertion failed` is logged. If provided, the error `message` is formatted
157158
using [`util.format()`][] by passing along all message arguments. The output is
158159
used as the error message.
@@ -162,6 +163,8 @@ console.assert(true, 'does nothing');
162163
// OK
163164
console.assert(false, 'Whoops %s work', 'didn\'t');
164165
// Assertion failed: Whoops didn't work
166+
console.assert();
167+
// Assertion failed
165168
```
166169

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

0 commit comments

Comments
 (0)