diff --git a/README.md b/README.md index 461d69f..6647261 100644 --- a/README.md +++ b/README.md @@ -1189,10 +1189,10 @@ function onThingHappended(cb){ // good var hero = { - firstName: 'Bob' - , lastName: 'Parr' - , heroName: 'Mr. Incredible' - , superPower: 'strength' + firstName: 'Bob' + , lastName: 'Parr' + , heroName: 'Mr. Incredible' + , superPower: 'strength' } ``` @@ -1204,28 +1204,78 @@ function onThingHappended(cb){ // bad var hero = { firstName: 'Kevin' - , lastName: 'Flynn' - , + , lastName: 'Flynn' + , } var heroes = [ 'Batman' - , 'Superman' - , + , 'Superman' + , ] // good var hero = { firstName: 'Kevin' - , lastName: 'Flynn' + , lastName: 'Flynn' } var heroes = [ 'Batman' - , 'Superman' + , 'Superman' ] ``` + + + - Finally, commas should be aligned to be flush with the scope/declaration they exist under. This avoids using unecesarry whitespace/line-width bloating, as well as avoids the appearance of nesting where such is not the case. Think of it like a bullet-point list. + ```javascript + // bad + var hero = { + firstName: 'Bob' + , lastName: 'Parr' + , heroName: 'Mr. Incredible' + , superPower: 'strength' + } + + hero.extend({ + mask: true + , cape: { + color: 'red' + , length: 'medium' + } + , hairstyle: 'pompadour' + }) + + // good + var hero = { + firstName: 'Bob' + , lastName: 'Parr' + , heroName: 'Mr. Incredible' + , superPower: 'strength' + } + + hero.extend({ + mask: true + , cape: { + color: 'red' + , length: 'medium' + } + , hairstyle: 'pompadour' + }) + + //acceptable + var hero = { + firstName: 'Bob' + , lastName: 'Parr' + , heroName: 'Mr. Incredible' + , superPower: 'strength' + } + + var mecha + , lecha + , hiney + ``` ### Semicolons