I am totally confused by the article.
I use factory functions all the time and they are as old as JavaScript.
Definitely nothing to with ES6+
Instead they benefit from the closure concept
function createTimer() {
var count = 0;
return {
inc : function() { count++; },
getCount : function() { return count; },
reset : function() { count = 0; }
};
}
I am totally confused by the article. I use factory functions all the time and they are as old as JavaScript. Definitely nothing to with ES6+ Instead they benefit from the closure concept function createTimer() { var count = 0; return { inc : function() { count++; }, getCount : function() { return count; }, reset : function() { count = 0; } }; }