Skip to content

Instantly share code, notes, and snippets.

@michaelficarra
Last active Aug 4, 2019
Embed
What would you like to do?
a loose approximation of a potential Function.prototype.once
Function.prototype.once = function () {
let fn = this;
let called = false;
return function() {
if (!called) {
called = true;
return fn.apply(this, arguments);
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment