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

JS空格及换行 #2

Closed
fengliner opened this issue Jan 5, 2015 · 2 comments
Closed

JS空格及换行 #2

fengliner opened this issue Jan 5, 2015 · 2 comments

Comments

@fengliner
Copy link

匿名函数function后是否要有空格,比如:

function(param1, param2) {
// doSomething
}

还是

function (param1, param2) {
// doSomething
}

if语句是否必须要加{},哪怕只有一行代码,比如:

if (err) {
  console.log(err);
}

还是

if (err) console.log(err);

另外,我觉得代码规范,最好是对某些典型的语句写一个example,这样看起来会比较清晰

@crzidea
Copy link
Member

crzidea commented Jan 6, 2015

这两处地方不做硬性要求,主要是因为大家使用的编辑器的snippets插件可能不一样。例如vim-snippets中有两个snippets:

其他编辑器可能还会有不同。我们尽量保持原有的风格不做修改。
另外,javascript的代码风格基本沿用npm's "funny" coding style

@fengliner
Copy link
Author

OK

@crzidea crzidea changed the title bensheng JS空格及换行 Jan 6, 2015
@crzidea crzidea closed this as completed Jan 6, 2015
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

No branches or pull requests

2 participants