Node.js之console

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.inspectis 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错误。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值