如何检查'调试器;'关键字存在? [英] How to check if 'debugger;' keyword exists?

查看:137
本文介绍了如何检查'调试器;'关键字存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时开发人员忘记在javascript代码中删除调试器; ,并且在IE上产生javascript错误。
如果调试器存在,你如何检查(如控制台: if(window.console){console.log('foo');}

Sometimes some developers forgot to remove debugger; in javascript code, and it produce javascript error on IE. How can you check (like for the console: if(window.console){console.log('foo');}) if a debugger exists?

BTW:我不想检测浏览器是否是IE浏览器,如果可能的话我想要一个通用方法
谢谢,

BTW: I don't want to detect if the browser is IE, I want a generic method if possible Thanks,

推荐答案

你不能。

最好的解决办法是在你的版本控制系统中添加一个钩子防止代码包含调试器; 语句被提交/推送。

The best solution would be adding a hook to your version control system to prevent code containing debugger; statements from being committed/pushed.

要求你的开发人员搜索调试器; 或者至少在提交之前仔细查看差异也是一个解决方案 - 但不如VCS中的硬拒绝那样有效。

Asking your devs to search for debugger; or at least have a careful look at the diff before committing is also a solution - but not as effective as hard-rejecting in the VCS.

这篇关于如何检查'调试器;'关键字存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆