Javascript String toCacheKey()

Description

Javascript String toCacheKey()

/**//from   www . j a v  a 2  s. c o  m
 * transform string to numeric value
 * @returns {number}
 */
String.prototype.toCacheKey = function () {

    return this.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0);
};



PreviousNext

Related