1. The key inside the object does not distinguish the string
var a={};a[1]= "a"; a["1"]=2;console.log (a);
2, expand the array prototype, write a method to remove the array duplicates
//algorithm one, two-layer loop, poor performance Array.prototype.unique = function () {var len = this.length, I 22 comparison (array length greater than 1) while (--len > 0) {i = Len; while (-i >= 0) {//Previous index min 0 if (this[len] = = = This[i]) {//last item compared to previous item This.splice (i, 1); This.length automatically minus one, deleting the previous duplicates This.splice (Len, 1); This.length automatically minus one, delete the following duplicate item i--; }}} return this;};/ /algorithm two, performance optimization Array.prototype.unique = function () {var i, key, Len = this.length, cache = {},//Cached object ret = []; The array to return for (i = 0; i < len; i++) {key = typeof This[i] + this[i]; if (Cache[key]!== 1) {Cache[key] = 1; Ret.push (This[i]); }} return ret;;};/ /workaround three, directly using the Jquery.unique tool function var arr = [1,3,4,6,9,10,4,6];arr = Jquery.unique (arr); [1, 3, 4, 6, 9, ten]