Add tags

Add tags to the following comment
Object Type にも対応した書き方。
効率悪いとか言わない><

alert([1, 2, {}, {}, 2, 1].uniq()); // [1, 2, {}, {}]

var a = {};
alert([1, 2, a, a].uniq()); // [1, 2, {}]
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
Array.prototype.uniq = function () {
  for (var i = 0, r = [], s = []; i < this.length; i++) {
    for (var j = 0; j < s.length; j ++) 
      if (s[j] === this[i]) break;
    if (j == s.length) {
      r.push(this[i]);
      s.push(this[i]);
    }
  }
  return r;
};

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...