Skip to content

API console

Liu.Yandong.Hanks edited this page Aug 21, 2026 · 3 revisions

console

Console logging and named timing API.

Script API Reference

Overview

console writes script diagnostics to the host-configured standard output and standard error streams, and provides named timers for coarse measurements. It is a static object with no constructor.

Tip

Console output goes through the host, so it is comparatively expensive. Keep it out of hot execution paths and use it for diagnostics and development.

Methods

console.log(...values)

Parameters

Name Type Required Description
values any No Zero or more values to write, passed as variadic arguments.

Returns

null.

Behavior

Writes the values to standard output.

Example

console.log("loaded", 3);
return 0;

console.error(...values)

Parameters

Name Type Required Description
values any No Zero or more values to write, passed as variadic arguments.

Returns

null.

Behavior

Writes the values to standard error.

Example

console.error("invalid input", 42);
return 0;

console.time(label)

Parameters

Name Type Required Description
label string Yes Timer name. Use the same name with console.timeEnd.

Returns

null.

Behavior

Starts a named timer.

Example

console.time("build");
return 0;

console.timeEnd(label)

Parameters

Name Type Required Description
label string Yes Name of the timer to stop.

Returns

null.

Behavior

Stops the named timer and writes the elapsed time.

Example

console.time("work");
var value = 20 + 22;
console.timeEnd("work");
return value; // 42

Clone this wiki locally