JSFiddle - React, Tailwind, and code Playground
by f0t0n
JavaScript
'use strict';
var counter = (function() {
var counter = 0;
return {
increment: function() {
counter++;
},
decrement: function() {
counter --;
},
get: function() {
return counter;
}
};
})();
console.log('Initial value: %s\n---\n', counter.get());
counter.increment();
console.log(counter.get());
counter.decrement();
console.log(counter.get());