Javascript String toHash()

Description

Javascript String toHash()


String.prototype.toHash = function () {
  return this.split('').reduce((a, b) => {
    a = ((a << 5) - a) + b.charCodeAt(0)
    return a & a
  }, 0)/*  w  ww .j a  va  2s.  c  o  m*/
}



PreviousNext

Related