/** * @returns {string} */ function getUniqueClassName() { getUniqueClassName.count = getUniqueClassName.count || 1; var helper = () => { var count = getUniqueClassName.count++; var ret = ''; while (count > 0) { var curr = (count - 1) % 52; ret = String.fromCharCode((curr < 26) ? 97 /* a */ + curr : 65 /* A */ + (curr - 26)) + ret; count = Math.floor((count - 1) / 52); } return ret; } return helper(); } getUniqueClassName.reset = function() { getUniqueClassName.count = 0; } console.log(getUniqueClassName()); // a console.log(getUniqueClassName()); // b
Categories