-
-
Save skoon/590069 to your computer and use it in GitHub Desktop.
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
function setup(method) | |
{ | |
window[method] = fake; | |
}; | |
var fake = function() | |
{ | |
return "faked"; | |
}; | |
var real = function() | |
{ | |
return "real"; | |
}; | |
setup("real"); | |
console.log(real.toString()); | |
console.log(real() == "faked"); | |
/* this works but isn't as pretty */ | |
function setup(method) | |
{ | |
return fake; | |
}; | |
... | |
real = setup(real); | |
console.log(real() == "faked"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment