Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change == to === when comparing #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

change == to === when comparing #34

wants to merge 1 commit into from

Conversation

freewind
Copy link

@freewind freewind commented May 15, 2018

在JavaScript中,使用==!=进行比较时,容易产生意料之外的转型而导致潜在的bug,建议尽量使用===!==。(可参考如"JavaScript语言精粹”这样的书)

由于受影响的地方比较多,Review时请一定仔细一些

@ZhitingLin
Copy link
Contributor

感谢你的建议。因为有的地方,type是不一样的,但是还是需要比较内容。有的地方是故意要用==。 有个地方是能够用===的。但是这个还是影响比较大的。我们后续会考虑代码优化。

@freewind
Copy link
Author

freewind commented May 15, 2018

能否指出是故意要用==的地方,我想学习一下

另外,如果是故意要用==,是否可以把它包装成一个函数并加上提示,因为在当前的JavaScript最佳实践中,===是默认的选择。如果用了==但没有任何说明,可以会让人觉得这是一个误用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants