File tree Expand file tree Collapse file tree 1 file changed +20
-19
lines changed Expand file tree Collapse file tree 1 file changed +20
-19
lines changed Original file line number Diff line number Diff line change 70
70
71
71
## < a name= ' objects' > Objects< / a>
72
72
73
- - Use the literal syntax for object creation
73
+ - Use the literal syntax for object creation.
74
74
75
75
` ` ` javascript
76
76
// bad
161
161
var fullName = "Bob #{lastName}";
162
162
` ` `
163
163
164
- - String longer than 80 characters should be written across Multiple lines using string concatenation.
164
+ - Strings longer than 80 characters should be written across multiple lines using string concatenation.
165
165
166
166
` ` ` javascript
167
167
// bad
214
214
}
215
215
216
216
return items + '</ul>';
217
- };
217
+ }
218
218
219
219
// good
220
220
function inbox(messages) {
225
225
}
226
226
227
227
return '<ul>' + items.join('') + '</ul>';
228
- };
228
+ }
229
229
` ` `
230
230
231
231
** [[⬆]](#TOC )**
413
413
}
414
414
415
415
return name;
416
- };
416
+ }
417
417
418
418
// good
419
419
function () {
429
429
}
430
430
431
431
return name;
432
- };
432
+ }
433
433
434
434
// bad
435
435
function () {
637
637
// ...stuff...
638
638
639
639
return element;
640
- };
640
+ }
641
641
642
642
// good
643
643
/**
652
652
// ...stuff...
653
653
654
654
return element;
655
- };
655
+ }
656
656
` ` `
657
657
658
658
- Use ` // ` for single line comments. Place single line comments on a newline above the subject of the comment. Put an emptyline before the comment.
672
672
var type = this._type || 'no type';i
673
673
674
674
return type;
675
- };
675
+ }
676
676
677
677
// good
678
678
function getType() {
682
682
var type = this._type || 'no type';
683
683
684
684
return type;
685
- };
685
+ }
686
686
` ` `
687
687
688
688
** [[⬆]](#TOC )**
696
696
// bad
697
697
function() {
698
698
∙∙∙∙var name;
699
- };
699
+ }
700
700
701
701
// bad
702
702
function() {
706
706
// good
707
707
function() {
708
708
∙∙var name;
709
- };
709
+ }
710
710
` ` `
711
711
- Place 1 space before the leading brace.
712
712
713
713
` ` ` javascript
714
714
// bad
715
715
function test(){
716
716
console.log('test');
717
- };
717
+ }
718
718
719
719
// good
720
720
function test() {
721
721
console.log('test');
722
- };
722
+ }
723
723
724
724
// bad
725
725
dog.set('attr',{
911
911
// bad
912
912
function user(options){
913
913
this.name = options.name;
914
- };
914
+ }
915
915
916
916
var bad = new user({
917
917
name: 'nope'
920
920
// good
921
921
function User(options){
922
922
this.name = options.name;
923
- };
923
+ }
924
924
925
925
var good = new User({
926
926
name: 'yup'
992
992
options || (options = {});
993
993
var lightsaber = options.lightsaber || ' blue' ;
994
994
this.set(' lightsaber' , lightsaber);
995
- };
995
+ }
996
996
997
997
Jedi.prototype = {
998
998
set: function(key, val) {
1015
1015
```javascript
1016
1016
function Jedi() {
1017
1017
console.log(' new jedi ' );
1018
- };
1018
+ }
1019
1019
1020
1020
// bad
1021
1021
Jedi.prototype.fight = function fight() {
1083
1083
function Jedi(options) {
1084
1084
options || (options = {});
1085
1085
this.name = options.name || 'no name';
1086
- };
1086
+ }
1087
1087
1088
1088
Jedi.prototype = {
1089
1089
getName: function getName() {
@@ -1293,3 +1293,4 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1293
1293
** [[⬆]](#TOC )**
1294
1294
1295
1295
# };
1296
+
You can’t perform that action at this time.
0 commit comments