Created
August 10, 2013 10:27
-
-
Save glenjamin/6199934 to your computer and use it in GitHub Desktop.
Semi-colons I consider extraneous noise in JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When assigning a function to a variable | |
var times = function(n, f) { | |
for (var i=0; i<n; ++i) { | |
f(); | |
} | |
}/*here*/ | |
// When there's only one expression in a function | |
function(callback) { | |
doSomething(function(err, n) { callback(err, n * 2)/*here*/ })/*and here*/ | |
} | |
// When nesting functions that accept functions | |
describe("semi", function() { | |
describe("colons", function() { | |
it("aren't", function(){ | |
assert.ok(true); | |
})/*here*/ | |
it("really", function(){ | |
assert.equals(';', ";"); | |
})/*here*/ | |
it("necessary", function(){ | |
assert.throws(function() { | |
throw new Error(";;;;;"); | |
})/*here*/ | |
})/*here*/ | |
})/*here*/ | |
})/*here*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment