Home >Web Front-end >JS Tutorial >How to determine whether there are duplicates in an array using javascript_javascript skills

How to determine whether there are duplicates in an array using javascript_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 16:02:451136browse

The example in this article describes the method of using JavaScript to determine whether there are duplicates in an array. Share it with everyone for your reference. The details are as follows:

Array.prototype.del = function(){
   var a = {}, c = [], l = this.length;
   for (var i = 0; i < l; i++) {
     var b = this[i];
     var d = (typeof b) + b;
     if (a[d] === undefined) {
        c.push(b);
        a[d] = 1;
    }
   }
   return c;
}

I hope this article will be helpful to everyone’s JavaScript programming design.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn