... | @@ -69,8 +69,8 @@ It is preferred that each variable be given its own line and comment. They shoul |
... | @@ -69,8 +69,8 @@ It is preferred that each variable be given its own line and comment. They shoul |
|
|
|
|
|
```javascript
|
|
```javascript
|
|
var currentEntry; // currently selected table entry
|
|
var currentEntry; // currently selected table entry
|
|
var level; // indentation level
|
|
var level; // indentation level
|
|
var size; // size of table
|
|
var size; // size of table
|
|
```
|
|
```
|
|
JavaScript does not have block scope, so defining variables in blocks can confuse programmers who are experienced with other C family languages. Define all variables at the top of the function.
|
|
JavaScript does not have block scope, so defining variables in blocks can confuse programmers who are experienced with other C family languages. Define all variables at the top of the function.
|
|
|
|
|
... | @@ -85,15 +85,15 @@ There should be no space between the name of a function and the `(` (left parent |
... | @@ -85,15 +85,15 @@ There should be no space between the name of a function and the `(` (left parent |
|
|
|
|
|
```javascript
|
|
```javascript
|
|
|
|
|
|
function outer(c, d) {
|
|
function outer(c, d) {
|
|
var e = c * d;
|
|
var e = c * d;
|
|
|
|
|
|
function inner(a, b) {
|
|
function inner(a, b) {
|
|
return (e * a) + b;
|
|
return (e * a) + b;
|
|
}
|
|
}
|
|
|
|
|
|
return inner(0, 1);
|
|
return inner(0, 1);
|
|
}
|
|
}
|
|
```
|
|
```
|
|
|
|
|
|
This convention works well with JavaScript because in JavaScript, functions and object literals can be placed anywhere that an expression is allowed. It provides the best readability with inline functions and complex structures.
|
|
This convention works well with JavaScript because in JavaScript, functions and object literals can be placed anywhere that an expression is allowed. It provides the best readability with inline functions and complex structures.
|
... | | ... | |