Skip to content

Instantly share code, notes, and snippets.

@jonpemby
Created December 29, 2017 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonpemby/435347976f6b017bd55f4516f5019629 to your computer and use it in GitHub Desktop.
Save jonpemby/435347976f6b017bd55f4516f5019629 to your computer and use it in GitHub Desktop.
JavaScript once function
function once(fn, context) {
var result;
return function() {
if(fn) {
result = fn.apply(context || this, arguments);
fn = null;
}
return result;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment