Skip to content

API console

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

console

输出与命名计时

Output and named timing

脚本 API 目录

Script API Directory

概述

Overview

console 将脚本诊断输出交给宿主配置的标准输出、标准错误输出和计时器。它适合诊断和开发,不应成为高频热路径的一部分。

console sends script diagnostics to the host-configured standard output, standard error output, and timers. It is intended for diagnostics and development, not a hot execution path.

console.log(...values)

Parameters:

  • values
    零个或多个待输出值。

    Zero or more values to write.

Returns

null

null.

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

console.error(...values)

Parameters:

  • values
    零个或多个错误输出值。

    Zero or more values to write to standard error.

Returns

null

null.

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

console.time(label)

Parameters:

  • label
    计时器名称;应与 timeEnd 使用同一名称。

    Timer name; use the same name with timeEnd.

Returns

null

null.

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

console.timeEnd(label)

Parameters:

  • label
    要停止的计时器名称。

    Name of the timer to stop.

Returns

null,并写入经过时间。

null, while writing elapsed time.

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

Clone this wiki locally