_.memoize = function(func) { var alreadyCalled = false; var result; var arr = []; return function() { //console.log(arguments[0]); if (!alreadyCalled) { if ( !(arr.join(' ')).includes(arguments[0])) { arr.push(arguments[0]); result = func.apply(this, arguments); alreadyCalled = true; } else { //arr.push(arguments[0]); alreadyCalled = true; } return result; } return result; }; };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter