警报之间差异()和()在Javascriptconsole.log

警报之间差异()和()在Javascriptconsole.log
{ 1 }警报()

{ 1.1 }具有阻塞效应,而不是单击以确定,后续代码不能继续执行。

{ 1.2 }警报()只能输出字符串,如果报警输出的对象,自动调用toString()方法

如警报({1,2,3}); / / '1,2,3

{ 1.3 }警报不支持多个参数,只能输出第一个值。

如警报(1,2,3); / / 1

{ 2 } console.log()

{ 2.1 }打印表中的输出

{ 2.2 }可以打印任何类型的数据

例如console.log({1,2,3}); / / {1,2,3}

{ { 2.3 }支持多个参数

例如console.log(1,2,3) / 123

警戒console.log结果不同
得分= {1,2,3};
sortedscore = { };
console.log(评分);
sortedscore = score.sort(sortnumber)
console.log(sortedscore);
功能sortnumber(A,B){
返回一个;
}

上述输出:

{ 3, 2, 1 }

{ 3, 2, 1 }

但改为警戒:

得分= {1,2,3};
sortedscore = { };
警戒(得分);
sortedscore = score.sort(sortnumber)
警报(sortedscore);
功能sortnumber(A,B){
返回一个;
}
上述输出:

1, 2, 3

3, 2, 1

那是为什么它不应该是全部:

1, 2, 3

3, 2, 1
经过研究发现,这是Chrome实现的问题,输出没有得到适当的优化。对console.log实际执行的延迟,这相当于惰性的评价。当提到数组和对象的引用类型时,它将超越上述问题。

HTTPS: / / /错误。WebKit。org show_bug cgiid = 35801。
这是一个非常具有历史意义的bug,它已在上个月的开发版本中修复过。

tag:警报差异电脑软件Javascriptconsolelog

相关内容