不想的一个js去掉重复值的代码

<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=gbk" />
  <title>试试</title>
</head>

<script type="text/javascript">
var Hash = function() {
  this.hash = [];
  this.len = 0;
}

Hash.prototype = {
  put : function(key, value) {
    if(!this.hash[key]) {
      this.len++;
    }
    this.hash[key] = value;    
    return value;
  },

  remove : function(key) {
    var v = this.hash[key];
    if(v) {
      this.len--;
    }
    delete this.hash[key];
    return v;
  },

  toQueryString : function(prefix) {
    var str = [];
    for(var key in this.hash) {
      str.push(key + '=' + this.hash[key]);
    }
    if(prefix == true) {
      return '?' + encodeURI(str.join('&'));
    } else {
      return encodeURI(str.join('&'));
    }
  },

  keys : function() {
    return this.find('key');
  },

  values : function() {
    return this.find('value');
  },

  size : function() {
    return this.len;
  },

  find : function() {
    var action = arguments[0] || 'key';
    var isKey = action == 'key';
    var container = [];
    for(var key in this.hash) {
      container.push(isKey ? key : this.hash[key]);
    }
    return container;
  }
}

window.$ = function(id) {
  if(typeof id == 'string') {
    return document.getElementById(id);
  }
  return id;
}

window.onload = function() {
  initCity();
}

function initCity() {
  var hash = new Hash();
  hash.put('黑色头发', '010');
  hash.put('黑色头发', '010');
  hash.put('紫色头发', '021');
  hash.put('黑色头发', '022');
  hash.put('紫色头发', '021');

  var keys = hash.keys();
  var values = hash.values();

  var city = $('city');
  for(var i = 0; i < keys.length; i++) {
    city.options[city.options.length] = new Option(keys[i], values[i]);
  }
}
</script>


<style type="text/css">

</style>

<body>
  <form name="frm" method="post" action="#">
    <select id="city" name="city">
      <option value="">-- 请选择 --</option>
    </select>
  </form>
</body>
</html>




黑色头发:http://heisetoufa.iteye.com/admin/blogs/new