Skip to content

Commit 6d8db77

Browse files
author
Jake Champion
committed
chore: add reference docs for the new console methods
1 parent d8cc9ee commit 6d8db77

File tree

13 files changed

+363
-0
lines changed

13 files changed

+363
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
8+
# console.assert()
9+
10+
The **`console.assert()`** method writes an error message to
11+
the console if the assertion is false. If the assertion is true, nothing happens.
12+
13+
## Syntax
14+
15+
```js
16+
assert(assertion, obj1)
17+
assert(assertion, obj1, obj2)
18+
assert(assertion, obj1, obj2, /* … ,*/ objN)
19+
20+
assert(assertion, msg)
21+
assert(assertion, msg, subst1)
22+
assert(assertion, msg, subst1, /* … ,*/ substN)
23+
```
24+
25+
### Parameters
26+
27+
- `assertion`
28+
- : Any boolean expression. If the assertion is false, the message is written to the
29+
console.
30+
- `obj1``objN`
31+
- : A list of JavaScript objects to output. The string representations of each of these
32+
objects are appended together in the order listed and output.
33+
- `msg`
34+
- : A JavaScript string containing zero or more substitution strings.
35+
- `subst1``substN`
36+
- : JavaScript objects with which to replace substitution strings within
37+
`msg`. This parameter gives you additional control over the format of the
38+
output.
39+
40+
### Return value
41+
42+
`undefined`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
8+
# console.clear()
9+
10+
The **`console.clear()`** method clears the console if the console allows it.
11+
12+
## Syntax
13+
14+
```js
15+
clear()
16+
```
17+
18+
### Parameters
19+
20+
None.
21+
22+
### Return value
23+
24+
`undefined`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
8+
# console.count()
9+
10+
The **`console.count()`** method logs the number of times that
11+
this particular call to `count()` has been called.
12+
13+
14+
## Syntax
15+
16+
```js
17+
count()
18+
count(label)
19+
```
20+
21+
### Parameters
22+
23+
- `label` __optional__
24+
- : A string. If supplied, `count()` outputs the number of
25+
times it has been called with that label. If omitted, `count()` behaves as
26+
though it was called with the "default" label.
27+
28+
### Return value
29+
30+
`undefined`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
8+
# console.countReset()
9+
10+
The **`console.countReset()`** method resets counter used with `console.count()`.
11+
12+
## Syntax
13+
14+
```js
15+
countReset()
16+
countReset(label)
17+
```
18+
19+
### Parameters
20+
21+
- `label` __optional__
22+
- : A string. If supplied, `countReset()` resets the count for
23+
that label to 0. If omitted, `countReset()` resets the default counter to
24+
0.
25+
26+
### Return value
27+
28+
`undefined`.
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
8+
# console.dir()
9+
10+
The method **`console.dir()`** displays a list of the properties of
11+
the specified JavaScript object.
12+
13+
## Syntax
14+
15+
```js
16+
dir(object)
17+
```
18+
19+
### Parameters
20+
21+
- `object`
22+
- : A JavaScript object whose properties should be output.
23+
24+
### Return value
25+
26+
`undefined`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
8+
# console.dirxml()
9+
10+
The **`console.dirxml()`** method displays the supplied object in the console.
11+
12+
## Syntax
13+
14+
```js
15+
dirxml(object)
16+
```
17+
18+
### Parameters
19+
20+
- `object`
21+
- : A JavaScript object whose properties should be output.
22+
23+
### Return value
24+
25+
`undefined`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
8+
# console.group()
9+
10+
The **`console.group()`** method creates a new inline group in the console, until `console.groupEnd()` is called.
11+
12+
## Syntax
13+
14+
```js
15+
group()
16+
group(label)
17+
```
18+
19+
### Parameters
20+
21+
- `label` __optional__
22+
- : Label for the group.
23+
24+
### Return value
25+
26+
`undefined`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
8+
# console.groupCollapsed()
9+
10+
The **`console.groupCollapsed()`** method creates a new inline group in the Web Console. Unlike `console.group()`,
11+
however, the new group is created collapsed. The user will need to use the disclosure
12+
button next to it to expand it, revealing the entries created in the group.
13+
14+
Call `console.groupEnd()` to back out to the parent group.
15+
16+
## Syntax
17+
18+
```js
19+
groupCollapsed()
20+
groupCollapsed(label)
21+
```
22+
23+
### Parameters
24+
25+
- `label` __optional__
26+
- : Label for the group.
27+
28+
### Return value
29+
30+
`undefined`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
8+
# console.groupEnd()
9+
10+
The **`console.groupEnd()`** method exits the current inline group in the console.
11+
12+
## Syntax
13+
14+
```js
15+
groupEnd()
16+
```
17+
18+
### Parameters
19+
20+
None.
21+
22+
### Return value
23+
24+
`undefined`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
8+
# console.time()
9+
10+
The **`console.time()`** method starts a timer you can use to track
11+
how long an operation takes. You give each timer a unique name. When you call `console.timeEnd()` with the same name, the
12+
browser will output the time, in milliseconds, that elapsed since the timer was started.
13+
14+
## Syntax
15+
16+
```js
17+
time(label)
18+
```
19+
20+
### Parameters
21+
22+
- `label`
23+
- : A `string` representing the name to give the new timer. This will identify the timer; use the same name when
24+
calling `console.timeEnd()` to stop the timer and get the time output to
25+
the console.
26+
27+
### Return value
28+
29+
`undefined`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
8+
# console.timeEnd()
9+
10+
The **`console.timeEnd()`** stops a timer that was previously started by calling `console.time()`.
11+
12+
## Syntax
13+
14+
```js
15+
timeEnd(label)
16+
```
17+
18+
### Parameters
19+
20+
- `label`
21+
- : A `string` representing the name of the timer to stop. Once stopped, the elapsed time is automatically
22+
displayed in the console.
23+
24+
### Return value
25+
26+
`undefined`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
8+
# console.timeLog()
9+
10+
The **`console.timeLog()`** method logs the current value of a timer that was previously started by calling `console.time()`.
11+
12+
## Syntax
13+
14+
```js
15+
timeLog()
16+
timeLog(label)
17+
```
18+
19+
### Parameters
20+
21+
- `label` __optional__
22+
- : The name of the timer to log to the console. If this is omitted the label "default" is used.
23+
24+
### Return value
25+
26+
`undefined`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
hide_title: false
3+
hide_table_of_contents: false
4+
pagination_next: null
5+
pagination_prev: null
6+
---
7+
8+
# console.trace()
9+
10+
The **`console.trace()`** method outputs a stack trace to the console.
11+
12+
## Syntax
13+
14+
```js
15+
trace()
16+
trace(object1, /* …, */ objectN)
17+
```
18+
19+
### Parameters
20+
21+
- `objects` __optional__
22+
- : Zero or more objects to be output to console along with the trace. These are
23+
assembled and formatted the same way they would be if passed to the `console.log()` method.
24+
25+
### Return value
26+
27+
`undefined`.

0 commit comments

Comments
 (0)