JSFiddle - React, Tailwind, and code Playground

by QW01_01

JavaScript

var makeCounter = function(counterName){
	var c = 0;

    Object.defineProperty(window, counterName, {
      enumerable: false,
      configurable: false,
      get:function(){
          return c++;
      }
    });

}

makeCounter('counter');

counter;
counter;
counter;

console.log(counter);