[英]How do you debug Javascript applications?
I work in an application that is JavaScript intense. 我在一个JavaScript强大的应用程序中工作。 So to debug , I end up using many alerts.
所以为了调试,我最终使用了许多警报。 Are there other better ways to debug ?
还有其他更好的调试方法吗? What methods do you use ?
你用什么方法?
For JavaScript, debugging is a sinch in most browsers: 对于JavaScript,调试在大多数浏览器中都是一个难题:
IE - Where you really need to debug, F12 is the console. IE - 你真正需要调试的地方, F12是控制台。 You can call
console.log
, console.debug
, console.error
and a few others, and it will print out good data. 你可以调用
console.log
, console.debug
, console.error
和其他一些,它会打印出好的数据。 When you call console.log
on an object, good consoles will print out the property break-down of the object. 当您在对象上调用
console.log
时,良好的控制台将打印出对象的属性细分。 There's also an active dom inspector so that you can see what's going on as the script is running. 还有一个活跃的dom检查器,以便您可以看到脚本运行时发生了什么。
For all browsers, you can add Firebug Lite , but I really only use it for IE and Safari. 对于所有浏览器,您可以添加Firebug Lite ,但我实际上只将它用于IE和Safari。
Use Firefox as your main development platform and open the Web Console. 使用Firefox作为主要开发平台并打开Web控制台。 Error messages are printed there.
在那里打印错误消息。
Chrome also has a console, but it doesn't have Firebug, a Firefox add-on used for web development. Chrome还有一个控制台,但它没有Firebug,一个用于Web开发的Firefox插件。 While the Web Console that comes with Firefox will display errors in Javascript, Firebug will also help with inspecting the HTML for your page, and there are even extensions to Firebug like Flashbug for working with Flash components on your page.
虽然Firefox附带的Web控制台将在Javascript中显示错误,但Firebug也可以帮助检查页面的HTML,甚至还有Firebug的扩展,如Flashbug,用于处理页面上的Flash组件。
Obviously you'll want to check your web apps in all browsers eventually, but do most of your developing in Firefox. 显然,您最终会想要在所有浏览器中检查您的网络应用程序,但是在Firefox中进行大部分开发。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.