Advertisement
Guest User

Perfect code alignment with tabs and spaces

a guest
May 16th, 2014
532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // less complex alignment
  2.  
  3. function foo() {
  4.     var someVar = 1,                            // Some var
  5.         anotherVariable = 2,                    // Another var
  6.         isThing = someVar === anotherVariable;  // Is thing?
  7.  
  8.     if (someVar === otherVar) bar();    // If we're otherVar
  9.     else if (isThing)     otherFn();    // Do awesome stuff
  10.     else                     quux();    // Do bad stuff!!
  11.  
  12.     function bar() {
  13.         if (anotherVariable === 42) {       // Across block levels
  14.             anotherFunction();              // it still breaks
  15.         }
  16.     }
  17. }
  18.  
  19. // Much more complex everything aligned
  20.  
  21. function foo() {
  22.     var someVar = 1,                                // Some var
  23.         anotherVariable = 2,                        // Another var
  24.         isThing = someVar === anotherVariable;      // Is thing?
  25.  
  26.     if (someVar === otherVar) bar();                // If we're otherVar
  27.     else if (isThing)     otherFn();                // Do awesome stuff
  28.     else                     quux();                // Do bad stuff!!
  29.  
  30.     function bar() {
  31.         if (anotherVariable === 42) {               // Across block levels
  32.             anotherFunction();                      // it still breaks
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement