Created
April 20, 2010 22:10
-
-
Save coolaj86/373144 to your computer and use it in GitHub Desktop.
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
// Douglas Crockford's once | |
// Part 5: The End of All Things, Slide 39 | |
// Once or throw exception | |
function once(func) { | |
return function () { | |
var f = func; | |
func = null; | |
return f.apply(this, arguments); | |
} | |
}; | |
do_it(my_inputs, once(storer(my_object, 'blah'))); | |
// AJ ONeal | |
// Once or alert | |
function once(func) { | |
return function () { | |
var f = func; | |
func = null; | |
return f && f.apply(this, arguments) || alert('Did a bad thing...'); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment