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

说几条写 JavaScript 的基本规范? #77

Open
LuckyWinty opened this issue Oct 18, 2020 · 1 comment
Open

说几条写 JavaScript 的基本规范? #77

LuckyWinty opened this issue Oct 18, 2020 · 1 comment
Labels

Comments

@LuckyWinty
Copy link
Owner

No description provided.

@LuckyWinty
Copy link
Owner Author

(1)一个函数作用域中所有的变量声明应该尽量提到函数首部,用一个 var 声明,不允许出 现两个连续的 var 声明,声明时如果变量没有值,应该给该变量赋值对应类型的初始值,便于 他人阅读代码时,能够一目了然的知道变量对应的类型值。

(2)代码中出现地址、时间等字符串时需要使用常量代替。

(3)在进行比较的时候吧,尽量使用'===', '!=='代替'==', '!='。

(4)不要在内置对象的原型上添加方法,如 Array, Date。

(5)switch 语句必须带有 default 分支。

(6)for 循环必须使用大括号。

(7)if 语句必须使用大括号。

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

No branches or pull requests

1 participant