可能是一个无聊的问题,但为什么我们使用当前的JS编码模式? [英] Probably an inane question, but why do we use the current JS coding patterns?

查看:64
本文介绍了可能是一个无聊的问题,但为什么我们使用当前的JS编码模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不要反对谷物或任何东西(或不同意Douglas Crawford),但为什么这被认为是事实上的JS编码模式:

Not to go against the grain or anything (or disagree with Douglas Crawford), but why is this considered the de-facto JS coding pattern:

展开 | 选择 | Wrap | 行号

推荐答案

请参阅此主题在软件开发论坛中。它更通用。


顺便说一句,我更喜欢第一种方法而且我不明白为什么第二种方法必须更容易阅读。事实上,最后一个括号看起来像是关闭for循环,但这可能是因为我已经习惯了第一种方法。
See this thread in the Software Development forum. It''s more generic.

btw, I prefer the first method and I don''t see why the second one has to be easier to read. In fact, the last bracket looks like it closes the for loop, but that''s probably because I''m so used to the first method.



请参阅软件开发论坛中的此主题。它更通用。


顺便说一句,我更喜欢第一种方法而且我不明白为什么第二种方法必须更容易阅读。事实上,最后一个括号看起来像是关闭for循环,但这可能是因为我已经习惯了第一种方法。
See this thread in the Software Development forum. It''s more generic.

btw, I prefer the first method and I don''t see why the second one has to be easier to read. In fact, the last bracket looks like it closes the for loop, but that''s probably because I''m so used to the first method.



我用记事本表示编码,现在使用记事本+。 N +在直接内联时用红线突出显示代码块,但只有当它们缩进时才突出显示括号本身。

I stated coding with Notepad and now with Notepad+. N+ highlights the code blocks with red lines when they are directly inline with one another, but only highlights the brackets themselves when they are indented differently.

展开 | 选择 | Wrap | 行号



我实际上使用的是第一种方法。我从来没有支架问题,因为我也使用了缩进,所有括号都与命令对齐。


我不知道我是如何开始使用这种方法而不是第二种方法,但它被卡住了,我实际上发现第二种方法难看。如果我从某处复制代码或更改代码,我会将其更改为第一种样式(如果它不是很多代码)。为了节省更多的空间,如果在if,for,while等中只有一行代码,我也会完全摆脱括号。


只是个人习惯。
I actually use the first method. I''ve never had bracket problems because I use indenting too and all brackets line up with the command.

I don''t know how I started using this method as opposed to the second method, but it''s stuck and I actually find the second method unsightly. If I''m copying code from somewhere or altering code, I''ll change it to the first style (if it''s not a lot of code). To save even more space, I''ll also get rid of brackets altogether if it''s a single line of code in if, for, while, etc.

Just personal habits.



嗯,至少你是一致的。 = D好笑,当我得到的代码看起来像你写的那样,在同一行上有开括号,用函数语句内联关闭括号,我把它改成看起来我喜欢的方式。


但不好看!?来吧,即使是一个盲人也能看到我的方式看起来更漂亮。 = D


毕竟,在这一点上我似乎并不孤单。

Well, at least you''re consistent. =D Funny, when I get code that looks the way you write it, with opening bracket on the same line, closing bracket inline with the function statement, I change it to look the way I prefer.

But unsightly!? C''mon, even a blind man can see my way looks waaaay prettier. =D

It seems that I am not, after all, alone on this point.


这篇关于可能是一个无聊的问题,但为什么我们使用当前的JS编码模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆