interface
Console
interface Console
- readonly Console: {new (stdout: WritableStream, stderr?: WritableStream, ignoreErrors?: boolean) => Console; new (options: ConsoleOptions) => Console}
Asynchronously read lines from standard input (fd 0)
for await (const line of console) { console.log(line); }Clear the console
- @param data
something to display
Does nothing currently
- label?: string): void;
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. - label?: string): void;
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.
- tabularData?: any,properties?: string[]): void;
Try to construct a table with the columns of the properties of
tabularData(or useproperties) and rows oftabularDataand 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' │ // └────┴─────┘@param propertiesAlternate properties for constructing the table.
- @param label
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????"); - @param label
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????"); - ): number;
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"@param dataThe data to write
@returnsThe number of bytes written
This function is not available in the browser.