惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
H
Help Net Security
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
A
About on SuperTechFans
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享
aimingoo的专栏
aimingoo的专栏
F
Fortinet All Blogs
博客园 - 【当耐特】
Microsoft Security Blog
Microsoft Security Blog
Martin Fowler
Martin Fowler
I
InfoQ
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
Engineering at Meta
Engineering at Meta
腾讯CDC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
U
Unit 42
The Cloudflare Blog
Y
Y Combinator Blog

博客园 - chenping2008

连接远程数据库,得到数据插入本地表中 php复制目录 PHP删除目录 php统计目录大小 js秒数转换天时分秒 JS切换图片 js 游览器log的记录 2个iframe中checkbox联动 JS Clone函数 JS普通递归的改进 JS随机数的产生方法 JS相等运算符(==)和等同运算符(===) silverlight树形结构区服选择 Mongodb的一些基本概念 Mongodb在Ubuntu下的安装 redis windows下使用及redis命令 相册功能 Node.js 系列翻译---概要 补充Silverlight中图片显示
Node.js 系列翻译---console
chenping2008 · 2011-11-14 · via 博客园 - chenping2008

console(控制台)

console是标准的输出和错误。相似的,很多的web游览器都提供了console对象。

console.log()

输出内容到新的一行。与printf相似,console.log函数可以有多个参数。

console.log('count: %d', count);

如果第一个参数不是格式化的字符元素,那么就会对console.log中的每一个参数调用util.inspect函数。

其他的:

console.info()

console.warn()

console.error()

与console.log()函数都差不多。

统计操作执行的时间,可以用函数console.time(), console.timeEnd().

code:

console.time('the time-consuming of sum operate');

var sum=0;

for(var i=0;i<10000;i++)

{

sum+=i;

}

console.log('sum=%d',sum);

console.timeEnd('the time-consuming of sum operate');

result:

sum=49995000

the time-consuming of sum operate: 9ms

这个地方需要注意,time和timeEnd中不要输入中文,还有就是time和timeEnd中输入的参数要一致。

console.trace()

Print a stack trace to stderr of the current position.

console.assert() same as assert.ok()