Search the reference...
/
interface
Consoleinterface ConsoleAsynchronously read lines from standard input (fd 0)
for await (const line of console) {
console.log(line);
}
Clear the console
Increment a count
label counter
Log to stderr in your terminal
Appears in red
something to display
Does nothing currently
Does nothing currently
Does nothing currently
This method does not display anything unless used in the inspector. The console.profile() method starts a JavaScript CPU profile with an optional label until profileEnd is called. The profile is then added to the Profile panel of the inspector.
console.profile('MyLabel');
// Some code
console.profileEnd('MyLabel');
// Adds the profile 'MyLabel' to the Profiles panel of the inspector.
This method does not display anything unless used in the inspector. Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector. See profile for an example.
If this method is called without a label, the most recently started profile is stopped.
Try to construct a table with the columns of the properties of tabularData (or use properties) and rows of tabularData and log it. Falls back to just logging the argument if it can't be parsed as tabular.
// These can't be parsed as tabular data
console.table(Symbol());
// Symbol()
console.table(undefined);
// undefined
console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }]);
// ┌────┬─────┬─────┐
// │ │ a │ b │
// ├────┼─────┼─────┤
// │ 0 │ 1 │ 'Y' │
// │ 1 │ 'Z' │ 2 │
// └────┴─────┴─────┘
console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ['a']);
// ┌────┬─────┐
// │ │ a │
// ├────┼─────┤
// │ 0 │ 1 │
// │ 1 │ 'Z' │
// └────┴─────┘
Alternate properties for constructing the table.
Begin a timer to log with console.timeEnd
The label to use for the timer
console.time("how long????");
for (let i = 0; i 999999; i++) {
// do stuff
let x = i * i;
}
console.timeEnd("how long????");
End a timer to log with console.time
The label to use for the timer
console.time("how long????");
for (let i = 0; i 999999; i++) {
// do stuff
let x = i * i;
}
console.timeEnd("how long????");
Write text or bytes to stdout
Unlike console.log, this does no formatting and doesn't add a newline or spaces between arguments. You can pass it strings or bytes or any combination of the two.
console.write("hello world!", "\n"); // "hello world\n"
The data to write
The number of bytes written
This function is not available in the browser.
Resources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlogToolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco
We're hiring →interface Console | globals module | Bun,AI智能索引,全网链接索引,智能导航,网页索引
- [MDN Reference](https://developer.mozilla.org/docs/Web/API/console)