[1]alert()
[1.1]有阻塞作用,不点击确定,后续代码无法继续执行
[1.2]alert()只能输出string,如果alert输出的是对象会自动调用toString()方法
e.g. alert([1,2,3]);//'1,2,3'
[1.3]alert不支持多个参数的写法,只能输出第一个值
e.g. alert(1,2,3);//1
[2]console.log()
[2.1]在打印台输出
[2.2]可以打印任何类型的数据
e.g. console.log([1,2,3]);//[1,2,3]
[2.3]支持多个参数的写法
e.g. console.log(1,2,3)// 1 2 3
alert 和 console.log 的结果不同?
score = [1,2,3]; sortedScore = []; console.log(score); sortedScore = score.sort(sortNumber) console.log(sortedScore); function sortNumber(a, b) { return b - a; }
以上输出:
[3, 2, 1]
[3, 2, 1]
但是改成alert:
score = [1,2,3]; sortedScore = []; alert(score); sortedScore = score.sort(sortNumber) alert(sortedScore); function sortNumber(a, b) { return b - a; }
以上输出:
1, 2, 3
3, 2, 1
为什么会这样?不应该都是:
1, 2, 3
3, 2, 1
吗?
经过一番研究发现是chrome实现的问题,对输出做了不太合适的优化,把console.log的实际执行推迟,相当于“惰性”求值,遇上数组、对象这样的引用类型就出上面的问题了。
https://bugs.webkit.org/show_bug.cgi?id=35801
这是一个很有历史的 BUG,上个月在开发版已经修复了。
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年09月20日
2024年09月20日
- [电影原声带]黎允文《天将雄师》[FLAC+CUE]
- 曝NS继任机型已进入量产阶段:已花了30亿日元
- 不是Switch2?曝《马里奥惊奇》NS捆绑包即将公开
- 暖心任天堂!网友Switch维修返还时贴纸被完好保留
- 《国语老歌 经典对唱情歌 2CD》[WAV/分轨][1.1GB]
- 《刀郎 翻唱精选华语专辑 披着羊皮的狼 》[WAV+CUE][430MB]
- 《真的田震 中国乐坛红极一时的歌者 精品集》[WAV+CUE][300MB]
- 群星.1995-新滚石九大天王之情歌大全【滚石】【WAV+CUE】
- 群星.1993-滚石九大天王十二出好戏·纵夏欢唱【滚石】【WAV+CUE】
- 群星.1993-滚石九大天王十二出好戏·贺岁齐唱【滚石】【WAV+CUE】
- 黑神话悟空上品虫校尉精魄获取方法一览|上品虫校尉精魄收集攻略
- 《指环王:夏尔的传说》推迟至2025年初发行
- 黑神话悟空上品蝎太子精魄获取方法一览|上品蝎太子精魄收集攻略
- 银霞.1977-《台北66电影原声带》台湾复刻版[WAV+CUE]
- 银霞.1980-《你那好冷的小手》台湾珍藏纪念版[WAV+CUE]