Created
October 23, 2012 16:44
-
-
Save surjikal/3939997 to your computer and use it in GitHub Desktop.
Javascript Tests
This file contains 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
function decorator(fn) { | |
function wrapper() { | |
console.log('Before function.'); | |
var ret = fn.apply(this, arguments); | |
console.log('After function.'); | |
return ret; | |
} | |
return wrapper; | |
} | |
function foo(msg) { | |
console.log("[foo]", msg); | |
} | |
decorator(foo)('Hello there!'); |
This file contains 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
// These actually are valid! | |
// see http://mathiasbynens.be/notes/javascript-identifiers | |
var ಠ_ಠ = eval; | |
var Σ = function(arr) { | |
return arr.reduce(function(previous, current) { | |
return previous + current | |
}, 0); | |
} | |
console.log( Σ([1,2,3]) ); // 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment