@@ -152,24 +152,23 @@ changes:
152
152
* ` value ` {any} The value tested for being truthy.
153
153
* ` ...message ` {any} All arguments besides ` value ` are used as error message.
154
154
155
- A simple assertion test that verifies whether ` value ` is truthy. If it is not,
156
- or ` value ` is not passed,
157
- ` Assertion failed ` is logged. If provided, the error ` message ` is formatted
158
- using [ ` util.format() ` ] [ ] by passing along all message arguments. The output is
159
- used as the error message.
155
+ ` console.assert() ` writes a message if ` value ` is [ falsy] [ ] or omitted. It only
156
+ writes a message and does not otherwise affect execution. The output always
157
+ starts with ` "Assertion failed" ` . If provided, ` message ` is formatted using
158
+ [ ` util.format() ` ] [ ] .
159
+
160
+ If ` value ` is [ truthy] [ ] , nothing happens.
160
161
161
162
``` js
162
163
console .assert (true , ' does nothing' );
163
- // OK
164
+
164
165
console .assert (false , ' Whoops %s work' , ' didn\' t' );
165
166
// Assertion failed: Whoops didn't work
167
+
166
168
console .assert ();
167
169
// Assertion failed
168
170
```
169
171
170
- Calling ` console.assert() ` with a falsy assertion will only cause the ` message `
171
- to be printed to the console without interrupting execution of subsequent code.
172
-
173
172
### ` console.clear() `
174
173
<!-- YAML
175
174
added: v8.3.0
@@ -562,5 +561,7 @@ This method does not display anything unless used in the inspector. The
562
561
[ `util.format()` ] : util.html#util_util_format_format_args
563
562
[ `util.inspect()` ] : util.html#util_util_inspect_object_options
564
563
[ customizing `util.inspect()` colors ] : util.html#util_customizing_util_inspect_colors
564
+ [ falsy ] : https://developer.mozilla.org/en-US/docs/Glossary/Falsy
565
565
[ inspector ] : debugger.html
566
566
[ note on process I/O ] : process.html#process_a_note_on_process_i_o
567
+ [ truthy ] : https://developer.mozilla.org/en-US/docs/Glossary/Truthy
0 commit comments