coding-style

Declaring variables and functions, in what order?

[亡魂溺海] 提交于 2021-02-11 09:11:00
问题 Context I'm learning how to code in javascript consistently, readably and maintainably. I found nothing about the order of declaration of variables and functions. Example: var example = { A: function() { var a, b, c; }, B: function() { var a, b, c; }, C: function() { var a, b, c; } } Questions Alphabetically is the best one ? Is that the order can improve the speed of code execution ? 回答1: I use jslint to check the code quality. It can be integrated with Visual Studio and a lot of other stuff

Declaring variables and functions, in what order?

你。 提交于 2021-02-11 09:10:33
问题 Context I'm learning how to code in javascript consistently, readably and maintainably. I found nothing about the order of declaration of variables and functions. Example: var example = { A: function() { var a, b, c; }, B: function() { var a, b, c; }, C: function() { var a, b, c; } } Questions Alphabetically is the best one ? Is that the order can improve the speed of code execution ? 回答1: I use jslint to check the code quality. It can be integrated with Visual Studio and a lot of other stuff

Declaring variables and functions, in what order?

只愿长相守 提交于 2021-02-11 09:10:17
问题 Context I'm learning how to code in javascript consistently, readably and maintainably. I found nothing about the order of declaration of variables and functions. Example: var example = { A: function() { var a, b, c; }, B: function() { var a, b, c; }, C: function() { var a, b, c; } } Questions Alphabetically is the best one ? Is that the order can improve the speed of code execution ? 回答1: I use jslint to check the code quality. It can be integrated with Visual Studio and a lot of other stuff

Internal applications - why not make everything public?

青春壹個敷衍的年華 提交于 2021-02-07 14:46:55
问题 Is there a reason why I should not be marking everything as public in our intranet reporting app? No one outside out co will ever have access to this code - we have about 20 projects - mostly small and specific. Is there really a reason why we should be marking things anything other than public? I have my own thoughts on this which I'm trying to omit as I want this to be unbiased. (I have sexed up the title slightly) 回答1: Look up Encapsulation and/or "Information Hiding": In object-oriented

When should I use Scala's Array instead of one of the other collections?

做~自己de王妃 提交于 2021-02-07 12:28:44
问题 This is more a question of style and preference but here goes: when should I use scala.Array? I use List all the time and occasionally run into Seq, Map and the like, but I've never used nor seen Array in the wild. Is it just there for Java compatibility? Am I missing a common use-case? 回答1: First of all, let's make a disclaimer here. Scala 2.7's Array tries to be a Java Array and a Scala Collection at the same time. It mostly succeeds, but fail at both for some corner cases. Unfortunately,

Why is using side effects bad practice in JavaScript constructors?

我怕爱的太早我们不能终老 提交于 2021-02-07 05:47:26
问题 I use something quite similar to the design pattern custom objects in my code normally. But JSLint frowns upon constructs like this: function MyClass() { this.init(); } new MyClass(data); Because the object is being discarded immediately after creation - it isn't being used for anything. We can fool JSLint to ignore this by assigning it to a variable, but it doesn't change that JSLint (and I am guessing many JavaScript enthusiasts) discourages the pattern. So why is using side effects in a

Why is using side effects bad practice in JavaScript constructors?

一笑奈何 提交于 2021-02-07 05:47:19
问题 I use something quite similar to the design pattern custom objects in my code normally. But JSLint frowns upon constructs like this: function MyClass() { this.init(); } new MyClass(data); Because the object is being discarded immediately after creation - it isn't being used for anything. We can fool JSLint to ignore this by assigning it to a variable, but it doesn't change that JSLint (and I am guessing many JavaScript enthusiasts) discourages the pattern. So why is using side effects in a

Is there a recommended maximum line length for HTML or JavaScript? [closed]

我与影子孤独终老i 提交于 2021-02-06 06:42:40
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . Improve this question Most style guidelines for most programming languages recommend a maximum line length, typically 80 characters. This seems impractically short for HTML and JavaScript (when it is embedded in HTML). Is there a consensus on a practical line length limit for

Is there a recommended maximum line length for HTML or JavaScript? [closed]

天大地大妈咪最大 提交于 2021-02-06 06:36:22
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . Improve this question Most style guidelines for most programming languages recommend a maximum line length, typically 80 characters. This seems impractically short for HTML and JavaScript (when it is embedded in HTML). Is there a consensus on a practical line length limit for

Is there a recommended maximum line length for HTML or JavaScript? [closed]

拜拜、爱过 提交于 2021-02-06 06:33:56
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . Improve this question Most style guidelines for most programming languages recommend a maximum line length, typically 80 characters. This seems impractically short for HTML and JavaScript (when it is embedded in HTML). Is there a consensus on a practical line length limit for