web developer tips (49):将JS函数的左大括号置于新行

字体大小:


原文地址: how to set the editor to always place open braces on new line for functions in JScript?

在 Visual Studio 2008 ,菜单:工具+选项+文本编辑器+Jscript+格式设置,在“新行”选择中,选中“将函数的左大括号置于新行”。
http://www.watch-life.net/visual-studio/set-the-editor-to-always-place-open-braces-on-new-line-for-functions-in-jscript.html
image

也可以将控制块的左大括号置于新行。我喜欢这种大括号置于新行的方式,比较清晰,Visual Studio 2008 在js编辑功能方面加强了不少。

你可能也会喜欢以下文章:

永久链接(Permalink):http://www.watch-life.net/visual-studio/set-the-editor-to-always-place-open-braces-on-new-line-for-functions-in-jscript.html

Tags: , ,



  1. 网友评论( 1 )

在JS中,把大括号放在新行的开始并不是好的习惯。

return
{
status: true
};

你知道这会返回什么结果吗?与你期待的一致吗?

return {
status: true
};

才会与你期待的一致。

楼主可以参考一下javascript的自动纠错机制(auto semicolon insertion)

发表评论