I have the following function which is created from this StackOverflow question.
My question is regarding the parameters from the return function; (callback, ms, uniqueId)
.
In which scope are these variables added to when I run delayResizeEvent(func(), 500, "Unique name")
?
var delayResizeEvent = (function () {
'use strict';
var timers = {};
return function (callback, ms, uniqueId) {
if (!uniqueId) {
uniqueId = "Don't call this twice without a uniqueId";
}
if (timers[uniqueId]) {
clearTimeout(timers[uniqueId]);
}
timers[uniqueId] = setTimeout(callback, ms);
};
})();
I appreciate my wording may be a little off. If so please improve my quesetion.