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

使用tab还是2/4个空格? #2

Open
Jiavan opened this issue Mar 20, 2017 · 0 comments
Open

使用tab还是2/4个空格? #2

Jiavan opened this issue Mar 20, 2017 · 0 comments

Comments

@Jiavan
Copy link
Collaborator

Jiavan commented Mar 20, 2017

使用tab还是空格来进行缩进就好比说php是世界上最好的语言这种话题,每个人都有不同的习惯和看法,比较折中的解决方案是使用tab缩进,在IDE/Editor配置一个tab的长度为4/2空格。

目前大多数的JS开源项目采用了2个空格来进行缩进,包括node.js本身以及使用颇多的airbnb规范,其中比较多的人认为js使用2空格来缩进主要是因为es5之前的callback hell问题导致的,致使代码横向发展,可读性不强,但是现在已经有多种方法来解决callback hell横向发展阅读性不强的问题,比如使用promise。个人认为4空格可以具备更好视觉反馈和可读性,以及可以同时兼顾前后端开发。当然最重要的还是使用统一的编码规范,2/4空格都是可行的。

更多讨论

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

No branches or pull requests

1 participant