Skip to content

Commit b81fc84

Browse files
committed
Merge branch 'draedful-patch-1'
2 parents fa0f600 + cf07086 commit b81fc84

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed
Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
<!doctype html>
22
<htmllang="en">
3-
<head>
4-
<title>JavaScript Patterns</title>
5-
<metacharset="utf-8">
6-
</head>
7-
<body>
8-
<script>
9-
/* Title: Single var Pattern
10-
Description: use one var statement and declare multiple variables
11-
*/
3+
<head>
4+
<title>JavaScript Patterns</title>
5+
<metacharset="utf-8">
6+
</head>
7+
<body>
8+
<script>
9+
/* Title: Single var Pattern
10+
Description: use one var statement and declare multiple variables
11+
*/
1212

13-
/* Benefits:
14-
* 1. Provides a single place to look for all the local variables needed by the function
15-
* 2. Prevents logical errors when a variable is used before it's defined
16-
* 3. Helps you remember to declare variables and therefore minimize globals
17-
* 4. Is less code (to type and to transfer over the wire)
18-
*/
13+
/* Benefits:
14+
* 1. Provides a single place to look for all the local variables needed by the function
15+
* 2. Prevents logical errors when a variable is used before it's defined
16+
* 3. Helps you remember to declare variables and therefore minimize globals
17+
* 4. Is less code (to type and to transfer over the wire)
18+
*/
1919

20-
functionfunc(){
21-
vara=1
22-
,b=2
23-
,sum=a+b
24-
,myobject={}
25-
,i
26-
,j;
27-
28-
// function body...
29-
}
20+
functionfunc(){
21+
vara=1
22+
,b=2
23+
,sum=a+b
24+
,myobject={}
25+
,i
26+
,j;
3027

31-
functionupdateElement(){
32-
varel=document.getElementById("result")
33-
,style=el.style;
34-
// do something with el and style...
35-
}
28+
// function body...
29+
}
3630

37-
// Preferred way
38-
// Move commas BEFORE vars
39-
// You'll not forget to add one when adding variable to the end of list
40-
functionfunc(){
41-
vara=1
31+
functionupdateElement(){
32+
varel=document.getElementById("result")
33+
,style=el.style;
34+
// do something with el and style...
35+
}
36+
37+
// Preferred way
38+
// Move commas BEFORE vars
39+
// You'll not forget to add one when adding variable to the end of list
40+
functionfunc(){
41+
vara=1
4242
,b=2
4343
,sum=a+b
4444
,myobject={}
4545
,i
4646
,j;
4747

48-
// function body...
49-
}
48+
// function body...
49+
}
5050

51-
// References
52-
// http://net.tutsplus.com/tutorials/javascript-ajax/the-essentials-of-writing-high-quality-javascript/
53-
</script>
54-
</body>
55-
</html>
51+
// References
52+
// http://net.tutsplus.com/tutorials/javascript-ajax/the-essentials-of-writing-high-quality-javascript/
53+
</script>
54+
</body>
55+
</html>

0 commit comments

Comments
(0)