Skip to content

Commit

Permalink
Fix: nits and improvements for console pages - follow-up of #30065 (#…
Browse files Browse the repository at this point in the history
…30502)

* Remove MSDN ref/links - homogenize See also

* Reword 'web console' to 'console' since this also applies to server runtimes

* newline confusion

* another web/browser console ref

* Alt text supposed to be useful

* Consistency is not optional

* Old stories

* Static and backticks

* Consistency once again

* Typo

* Consistency but static
  • Loading branch information
SphinxKnight committed Nov 24, 2023
1 parent fc7310a commit 2288418
Show file tree
Hide file tree
Showing 23 changed files with 193 additions and 218 deletions.
27 changes: 13 additions & 14 deletions files/en-us/web/api/console/assert_static/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ browser-compat: api.console.assert_static

{{APIRef("Console API")}}

The **`console.assert()`** method writes an error message to
the console if the assertion is false. If the assertion is true, nothing happens.
The **`console.assert()`** static method writes an error message to the console if the assertion is false. If the assertion is true, nothing happens.

{{AvailableInWorkers}}

Expand All @@ -28,26 +27,21 @@ assert(assertion, msg, subst1, /* …, */ substN)
### Parameters

- `assertion`
- : Any boolean expression. If the assertion is false, the message is written to the
console.
- : Any boolean expression. If the assertion is false, the message is written to the console.
- `obj1``objN`
- : A list of JavaScript objects to output. The string representations of each of these
objects are appended together in the order listed and output.
- : A list of JavaScript objects to output. The string representations of each of these objects are appended together in the order listed and output to the console.
- `msg`
- : A JavaScript string containing zero or more substitution strings.
- : A JavaScript string containing zero or more substitution strings, which are replaced with `subst1` through `substN` in consecutive order.
- `subst1``substN`
- : JavaScript objects with which to replace substitution strings within
`msg`. This parameter gives you additional control over the format of the
output.
- : JavaScript objects with which to replace substitution strings within `msg`. This gives you additional control over the format of the output. See [Using string substitutions](/en-US/docs/Web/API/console#using_string_substitutions) for a description of how substitutions work.

### Return value

None ({{jsxref("undefined")}}).

## Examples

The following code example demonstrates the use of a JavaScript object following the
assertion:
The following code example demonstrates the use of a JavaScript object following the assertion:

```js
const errorMsg = "the # is not even";
Expand All @@ -64,8 +58,7 @@ for (let number = 2; number <= 5; number++) {
// Assertion failed: {number: 5, errorMsg: "the # is not even"}
```

See [Using string substitutions](/en-US/docs/Web/API/console#using_string_substitutions) in the documentation of {{domxref("console")}} for further
details.
See [Using string substitutions](/en-US/docs/Web/API/console#using_string_substitutions) in the documentation of {{domxref("console")}} for further details.

## Specifications

Expand All @@ -74,3 +67,9 @@ details.
## Browser compatibility

{{Compat}}

## See also

- [Microsoft Edge's documentation for `console.assert()`](https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/console/api#assert)
- [Node.JS documentation for `console.assert()`](https://nodejs.org/docs/latest/api/console.html#consoleassertvalue-message)
- [Google Chrome's documentation for `console.dir()`](https://developer.chrome.com/docs/devtools/console/api/#dir)
8 changes: 7 additions & 1 deletion files/en-us/web/api/console/clear_static/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ browser-compat: api.console.clear_static

{{APIRef("Console API")}}

The **`console.clear()`** method clears the console if the console allows it. A graphical console, like those running on browsers, will allow it; a console displaying on the terminal, like the one running on Node, will not support it, and will have no effect (and no error).
The **`console.clear()`** static method clears the console if the console allows it. A graphical console, like those running on browsers, will allow it; a console displaying on the terminal, like the one running on Node, will not support it, and will have no effect (and no error).

## Syntax

Expand All @@ -31,3 +31,9 @@ None ({{jsxref("undefined")}}).
## Browser compatibility

{{Compat}}

## See also

- [Microsoft Edge's documentation for `console.clear()`](https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/console/api#clear)
- [Node.JS documentation for `console.clear()`](https://nodejs.org/docs/latest/api/console.html#consoleclear)
- [Google Chrome's documentation for `console.clear()`](https://developer.chrome.com/docs/devtools/console/api/#clear)
16 changes: 9 additions & 7 deletions files/en-us/web/api/console/count_static/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ browser-compat: api.console.count_static

{{APIRef("Console API")}}

The **`console.count()`** method logs the number of times that
this particular call to `count()` has been called.
The **`console.count()`** static method logs the number of times that this particular call to `count()` has been called.

{{AvailableInWorkers}}

Expand All @@ -23,9 +22,7 @@ count(label)
### Parameters

- `label` {{Optional_Inline}}
- : A string. If supplied, `count()` outputs the number of
times it has been called with that label. If omitted, `count()` behaves as
though it was called with the "default" label.
- : A string. If supplied, `count()` outputs the number of times it has been called with that label. If omitted, `count()` behaves as though it was called with the "default" label.

### Return value

Expand Down Expand Up @@ -62,8 +59,7 @@ Console output will look something like this:

The label is displayed as `default` because no explicit label was supplied.

If we pass the `user` variable as the `label` argument to the
first invocation of `count()`, and the string "alice" to the second:
If we pass the `user` variable as the `label` argument to the first invocation of `console.count()`, and the string "alice" to the second:

```js
let user = "";
Expand Down Expand Up @@ -99,3 +95,9 @@ We're now maintaining separate counts based only on the value of `label`.
## Browser compatibility

{{Compat}}

## See also

- [Microsoft Edge's documentation for `console.count()`](https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/console/api#count)
- [Node.JS documentation for `console.count()`](https://nodejs.org/docs/latest/api/console.html#consolecountlabel)
- [Google Chrome's documentation for `console.count()`](https://developer.chrome.com/docs/devtools/console/api/#count)
23 changes: 11 additions & 12 deletions files/en-us/web/api/console/countreset_static/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ browser-compat: api.console.countReset_static

{{APIRef("Console API")}}

The **`console.countReset()`** method resets counter used with
{{domxref("console.count()")}}.
The **`console.countReset()`** static method resets counter used with {{domxref("console.count()")}}.

{{AvailableInWorkers}}

Expand All @@ -23,9 +22,7 @@ countReset(label)
### Parameters

- `label` {{optional_inline}}
- : A string. If supplied, `countReset()` resets the count for
that label to 0. If omitted, `countReset()` resets the default counter to
0\.
- : A string. If supplied, `countReset()` resets the count for that label to 0. If omitted, `countReset()` resets the default counter to 0.

### Return value

Expand Down Expand Up @@ -62,12 +59,9 @@ Console output will look something like this:
"default: 0"
```

Note that the call to `console.counterReset()` resets the value of the
default counter to zero.
Note that the call to `console.counterReset()` resets the value of the default counter to zero.

If we pass the `user` variable as the `label` argument with the
string "bob" to the first invocation of `count()`, and the string "alice" to
the second:
If we pass the `user` variable as the `label` argument with the string "bob" to the first invocation of `console.count()`, and the string "alice" to the second:

```js
let user = "";
Expand Down Expand Up @@ -96,8 +90,7 @@ We will see output like this:
"alice: 3"
```

Resetting the value of the counter "bob" only changes the value of that counter. The
value of "alice" is unchanged.
Resetting the value of the counter "bob" only changes the value of that counter. The value of "alice" is unchanged.

## Specifications

Expand All @@ -106,3 +99,9 @@ value of "alice" is unchanged.
## Browser compatibility

{{Compat}}

## See also

- [Microsoft Edge's documentation for `console.countReset()`](https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/console/api#countreset)
- [Node.JS documentation for `console.countReset()`](https://nodejs.org/docs/latest/api/console.html#consolecountresetlabel)
- [Google Chrome's documentation for `console.countReset()`](https://developer.chrome.com/docs/devtools/console/api/#countreset)
25 changes: 11 additions & 14 deletions files/en-us/web/api/console/debug_static/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ browser-compat: api.console.debug_static

{{APIRef("Console API")}}

The **`console.debug()`** method outputs a message to the web console at
the "debug" log level. The message is only displayed to the user if the console is configured to
display debug output. In most cases, the log level is configured within the console UI. This log
level might correspond to the `Debug` or `Verbose` log level.
The **`console.debug()`** static method outputs a message to the console at the "debug" log level. The message is only displayed to the user if the console is configured to display debug output. In most cases, the log level is configured within the console UI. This log level might correspond to the `Debug` or `Verbose` log level.

{{AvailableInWorkers}}

Expand All @@ -27,19 +24,13 @@ debug(msg, subst1, /* …, */ substN)
### Parameters

- `obj1``objN`
- : A list of JavaScript objects to output. The string representations of each of these
objects are appended together in the order listed and output to the console.
- : A list of JavaScript objects to output. The string representations of each of these objects are appended together in the order listed and output to the console.
- `msg`
- : A JavaScript string containing zero or more substitution strings, which are replaced
with `subst1` through `substN` in consecutive order.
- : A JavaScript string containing zero or more substitution strings, which are replaced with `subst1` through `substN` in consecutive order.
- `subst1``substN`
- : JavaScript objects with which to replace substitution strings within
`msg`. This gives you additional control over the format of the output. See
[Using string substitutions](/en-US/docs/Web/API/console#using_string_substitutions) for a
description of how substitutions work.
- : JavaScript objects with which to replace substitution strings within `msg`. This gives you additional control over the format of the output. See [Using string substitutions](/en-US/docs/Web/API/console#using_string_substitutions) for a description of how substitutions work.

See [Outputting text to the console](/en-US/docs/Web/API/console#outputting_text_to_the_console) in the documentation of the {{domxref("console")}} object for
details.
See [Outputting text to the console](/en-US/docs/Web/API/console#outputting_text_to_the_console) in the documentation of the {{domxref("console")}} object for details.

### Return value

Expand All @@ -52,3 +43,9 @@ None ({{jsxref("undefined")}}).
## Browser compatibility

{{Compat}}

## See also

- [Microsoft Edge's documentation for `console.debug()`](https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/console/api#debug)
- [Node.JS documentation for `console.debug()`](https://nodejs.org/docs/latest/api/console.html#consoledebugdata-args)
- [Google Chrome's documentation for `console.debug()`](https://developer.chrome.com/docs/devtools/console/api/#debug)
15 changes: 6 additions & 9 deletions files/en-us/web/api/console/dir_static/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@ browser-compat: api.console.dir_static

{{APIRef("Console API")}}

The method **`console.dir()`** displays an interactive list of the properties of
the specified JavaScript object. The output is presented as a hierarchical
listing with disclosure triangles that let you see the contents of child objects.
The **`console.dir()`** static method displays an interactive list of the properties of the specified JavaScript object. The output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects.

In other words, `console.dir()` is the way to see all the properties of a
specified JavaScript object in console by which the developer can easily get the
properties of the object.
In other words, `console.dir()` is the way to see all the properties of a specified JavaScript object in console by which the developer can easily get the properties of the object.

{{AvailableInWorkers}}

![console-dir.png](console-dir.png)
![A screenshot of the Firefox console where console.dir(document.location) is run. We can see the URL of the page, followed by a block of properties. If the property is a fonction or an object, a disclosure triangle is prepended.](console-dir.png)

## Syntax

Expand All @@ -45,5 +41,6 @@ None ({{jsxref("undefined")}}).

## See also

- [MSDN: Using the F12 Tools Console to View Errors and Status](<https://docs.microsoft.com/previous-versions/windows/internet-explorer/ie-developer/samples/gg589530(v=vs.85)>)
- [Chrome Console API reference](https://developer.chrome.com/docs/devtools/console/api/#dir)
- [Microsoft Edge's documentation for `console.dir()`](https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/console/api#dir)
- [Node.JS documentation for `console.dir()`](https://nodejs.org/docs/latest/api/console.html#consoledirobj-options)
- [Google Chrome's documentation for `console.dir()`](https://developer.chrome.com/docs/devtools/console/api/#dir)
11 changes: 7 additions & 4 deletions files/en-us/web/api/console/dirxml_static/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ browser-compat: api.console.dirxml_static

{{APIRef("Console API")}}

The **`console.dirxml()`** method displays an interactive tree of the descendant elements of the specified XML/HTML
element. If it is not possible to display as an element the JavaScript Object view is
shown instead. The output is presented as a hierarchical listing of expandable nodes
that let you see the contents of child nodes.
The **`console.dirxml()`** static method displays an interactive tree of the descendant elements of the specified XML/HTML element. If it is not possible to display as an element the JavaScript Object view is shown instead. The output is presented as a hierarchical listing of expandable nodes that let you see the contents of child nodes.

## Syntax

Expand All @@ -35,3 +32,9 @@ None ({{jsxref("undefined")}}).
## Browser compatibility

{{Compat}}

## See also

- [Microsoft Edge's documentation for `console.dirxml()`](https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/console/api#dirxml)
- [Node.JS documentation for `console.dirxml()`](https://nodejs.org/docs/latest/api/console.html#consoledirxmldata)
- [Google Chrome's documentation for `console.dirxml()`](https://developer.chrome.com/docs/devtools/console/api/#dirxml)
18 changes: 8 additions & 10 deletions files/en-us/web/api/console/error_static/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ browser-compat: api.console.error_static

{{APIRef("Console API")}}

The **`console.error()`** method outputs an error message to the Web console.
The **`console.error()`** static method outputs an error message to the console.

{{AvailableInWorkers}}

Expand All @@ -24,16 +24,13 @@ error(msg, subst1, /* …, */ substN)
### Parameters

- `obj1``objN`
- : A list of JavaScript objects to output. The string representations of each of
these objects are appended together in the order listed and output.
- : A list of JavaScript objects to output. The string representations of each of these objects are appended together in the order listed and output to the console.
- `msg`
- : A JavaScript string containing zero or more substitution strings.
- : A JavaScript string containing zero or more substitution strings, which are replaced with `subst1` through `substN` in consecutive order.
- `subst1``substN`
- : JavaScript objects with which to replace substitution strings within
`msg`. This gives you additional control over the format of the output.
- : JavaScript objects with which to replace substitution strings within `msg`. This gives you additional control over the format of the output. See [Using string substitutions](/en-US/docs/Web/API/console#using_string_substitutions) for a description of how substitutions work.

See [Outputting text to the console](/en-US/docs/Web/API/console#outputting_text_to_the_console) in the documentation of {{domxref("console")}} for
details.
See [Outputting text to the console](/en-US/docs/Web/API/console#outputting_text_to_the_console) in the documentation of the {{domxref("console")}} object for details.

### Return value

Expand All @@ -49,5 +46,6 @@ None ({{jsxref("undefined")}}).

## See also

- [MSDN: Using the F12 Tools Console to View Errors and Status](<https://docs.microsoft.com/previous-versions/windows/internet-explorer/ie-developer/samples/gg589530(v=vs.85)>)
- [Chrome Developer Tools: Using the Console](https://developer.chrome.com/docs/devtools/console/api/#error)
- [Microsoft Edge's documentation for `console.error()`](https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/console/api#error)
- [Node.JS documentation for `console.error()`](https://nodejs.org/docs/latest/api/console.html#consoleerrordata-args)
- [Google Chrome's documentation for `console.error()`](https://developer.chrome.com/docs/devtools/console/api/#error)
15 changes: 7 additions & 8 deletions files/en-us/web/api/console/group_static/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ browser-compat: api.console.group_static

{{APIRef("Console API")}}

The **`console.group()`** method creates a new inline group in the [Web console](https://firefox-source-docs.mozilla.org/devtools-user/web_console/index.html) log, causing any subsequent console messages to be indented by an additional level,
until {{domxref("console.groupEnd()")}} is called.
The **`console.group()`** static method creates a new inline group in the console log, causing any subsequent console messages to be indented by an additional level, until {{domxref("console.groupEnd()")}} is called.

{{AvailableInWorkers}}

Expand All @@ -31,13 +30,9 @@ None ({{jsxref("undefined")}}).

## Examples

You can use nested groups to help organize your output by visually associating related
messages. To create a new nested block, call `console.group()`. The
`console.groupCollapsed()` method is similar, but the new block is
collapsed and requires clicking a disclosure button to read it.
You can use nested groups to help organize your output by visually associating related messages. To create a new nested block, call `console.group()`. The `console.groupCollapsed()` method is similar, but the new block is collapsed and requires clicking a disclosure button to read it.

To exit the current group, call `console.groupEnd()`.
For example, given this code:
To exit the current group, call `console.groupEnd()`. For example, given this code:

```js
console.log("This is the outer level");
Expand Down Expand Up @@ -69,3 +64,7 @@ See [Using groups in the console](/en-US/docs/Web/API/console#using_groups_in_th
## See also

- {{domxref("console.groupEnd()")}}
- {{domxref("console.groupCollapsed()")}}
- [Microsoft Edge's documentation for `console.group()`](https://learn.microsoft.com/en-us/microsoft-edge/devtools-guide-chromium/console/api#group)
- [Node.JS documentation for `console.group()`](https://nodejs.org/docs/latest/api/console.html#consolegrouplabel)
- [Google Chrome's documentation for `console.group()`](https://developer.chrome.com/docs/devtools/console/api/#group)
Loading

0 comments on commit 2288418

Please sign in to comment.