1234567891011121314151617181920function once(fn, context) { var result; return function() { if(fn) { result = fn.apply(context || this, arguments); fn = null; } return result; };} // Usagevar canOnlyFireOnce = once(function() { console.log('Fired!');}); canOnlyFireOnce(); // "Fired!"canOnlyFireOnce(); // nadacs https://davidwalsh.name/javascript-once JavaScript Once Function Learn how to ensure ..