Created
October 12, 2011 17:29
-
-
Save chakrit/1281902 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
<html> | |
<head> | |
<script type="text/javascript"> | |
function foo() { alert("FOO"); } | |
function bar() { alert("BAR"); } | |
// UNCOMMENT CODE TO SEE EFFECT | |
/* var useBar = false; | |
foo = (function(oldFoo) { | |
return function() { | |
if (useBar) { bar(); } else { oldFoo(); } | |
}; | |
})(foo); */ | |
function button_click() { | |
foo(); | |
} | |
function change_click() { | |
useBar = !useBar; | |
} | |
</script> | |
</head> | |
<body> | |
<button onclick="button_click()">Click me</button> | |
<button onclick="change_click()">Change handler</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Commented out code: