简体   繁体   English

我应该使用JavaScript验证程序吗?

[英]Should I use a JavaScript validator?

I've tested my JavaScript in several browsers and it all works fine. 我已经在几种浏览器中测试过我的JavaScript,并且一切正常。 However when I run it through JSLint , there are a few (minor) errors it picks up. 但是,当我通过JSLint运行它时,它会遇到一些(较小)错误。

If the code works, is it important to fix these? 如果代码有效,修复这些错误是否重要?

If the code works, then they probably aren't errors. 如果代码有效,那么它们可能不是错误。 JSLint is a Lint, not a validator and a very large part of what it does is enforce Douglas Crockford's ideas about best practices. JSLint是Lint,不是验证程序,它所做的很大一部分是强制执行Douglas Crockford关于最佳实践的想法。

That said, they are mostly pretty good best practices, and following them is usually a good idea. 也就是说,它们大多数都是非常好的最佳实践,遵循它们通常是一个好主意。

I'd say yes. 我会说是的。 If JSLint is telling you something is wrong, best to act on it. 如果JSLint告诉您出了什么问题,最好采取措施。

Personally, knowing there were errors would nag me. 就个人而言,知道有错误会使我烦恼。 I wouldn't be deterred by the fact that the code "works". 我不会被代码“有效”的事实吓住了。 I couldn't be certain that these "minor" errors - your judgment - would not cause a problem in the future. 我不确定这些“较小”错误-您的判断-将来不会造成问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM