为什么console.log()被认为比alert()更好? [英] Why is console.log() considered better than alert()?
本文介绍了为什么console.log()被认为比alert()更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
console.log()
方法优于简单地使用 alert()
方法。为什么是这样?有没有一个很好的例子有人可以指出我在哪里 console.log()
显然是更好的选择?解决方案
-
alert()
正在阻止 -
alert()
不能在非调试环境中轻松抑制 -
控制台
通常格式化对象很好,并允许遍历他们 - 日志记录通常有一个交互式指针,代码发出日志记录
- 你不能看多个
alert()
一次消息 -
控制台
可以具有不同的日志记录级别直观格式化
I've always been told that when debugging an application, JavaScript's console.log()
method is preferred over simply using an alert()
method. Why is this? Is there a good example someone can point me to where console.log()
is obviously the better choice?
解决方案
alert()
is blockingalert()
cannot be easily suppressed in non-debug environmentconsole
typically formats your objects nicely and allows to traverse them- logging statements often have an interactive pointer to code which issued logging statement
- you cannot look at more than one
alert()
message at a time console
s can have different logging levels with intuitive formatting
这篇关于为什么console.log()被认为比alert()更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文