Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b329a95

Browse filesBrowse files
iandrcaddaleax
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 <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>
1 parent 9027a87 commit b329a95
Copy full SHA for b329a95

File tree

Expand file treeCollapse file tree

1 file changed

+3
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-0
lines changed
Open diff view settings
Collapse file

‎doc/api/console.md‎

Copy file name to clipboardExpand all lines: doc/api/console.md
+3Lines changed: 3 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.