console#
Stability: 4 - API Frozen
- {Object}
For printing to stdout and stderr. Similar to the console object functions provided by most web browsers, here the output is sent to stdout or stderr.
将信息打印到标准输出和标准错误中。和大多数web浏览器提供的console方法一样,输出被发送给标准输出或标准错误。
console.log([data], [...])#
Prints to stdout with newline. This function can take multiple arguments in aprintf()
-like way. Example:
以换行符结尾打印到标准输出中。该方法像printf()方法一样可以接受多个参数。列子如下:
console.log('count: %d', count);
If formatting elements are not found in the first string then util.inspect
is used on each argument. See util.format() for more information.
更多的格式请查看util.format()方法
console.info([data], [...])#
Same as console.log
.
和上个方法一样
console.error([data], [...])#
Same as console.log
but prints to stderr.
打印到标准错误中,使用方法和console.log一样
console.warn([data], [...])#
Same as console.error
.
同上
console.dir(obj)#
Uses util.inspect
on obj
and prints resulting string to stdout.
对obj参数使用util.inspect方法并打印结果字符串到标准输出
console.time(label)#
Mark a time.
标记一个时间
console.timeEnd(label)#
Finish timer, record output. Example:
结束时间标记,记录输出。实例如下:
console.time('100-elements');
for (var i = 0; i < 100; i++) {
;
}
console.timeEnd('100-elements');
console.trace(label)#
Print a stack trace to stderr of the current position.
打印一个堆栈跟踪到标准错误的当前位置上。
console.assert(expression, [message])#
Same as assert.ok() where if the expression
evaluates as false
throw an AssertionError with message
.
和assert.ok()一样,当expression语句结果为false是抛出一个带有信息的AssertionError错误。