//完美去除法:
var arr=[1,3,2,2,11,4];
var arr1=[];
var arr2=arr.sort(function(a,b){
return a-b;
}); //把数组进行排序
var num=1;
for (var i=0;i<arr2.length;i++){
if(arr2[i]!==arr2[(num++)]){
arr1.push(arr[i]);
}
}
console.log(arr1);

怎么去掉javascript 的Array的重复项的更多相关文章

  1. 利用JavaScript去掉数组中重复项

    利用JavaScript的object的特性,我们可以非常容易的实现将一个数组的重复项去掉. object的特性是:key一定是唯一的. 把数组重复项去掉: 1 将数组转换成一个object对象,数组 ...

  2. jquery 去掉重复项(splice,apply,push)

    /* js数组去掉重复项 var somearray = [1,1,2,2,3,3,4,4,'1']; somearray.check(); //somearray will return arr=[ ...

  3. [LeetCode] Find All Duplicates in an Array 找出数组中所有重复项

    Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others ...

  4. [LeetCode] Remove Duplicates from Sorted Array II 有序数组中去除重复项之二

    Follow up for "Remove Duplicates":What if duplicates are allowed at most twice? For exampl ...

  5. [LeetCode] Remove Duplicates from Sorted Array 有序数组中去除重复项

    Given a sorted array, remove the duplicates in place such that each element appear only once and ret ...

  6. LeetCode 442. Find All Duplicates in an Array (在数组中找到所有的重复项)

    Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others ...

  7. [LeetCode] 80. Remove Duplicates from Sorted Array II ☆☆☆(从有序数组中删除重复项之二)

    https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/discuss/27976/3-6-easy-lines-C% ...

  8. [LeetCode] 26. Remove Duplicates from Sorted Array ☆(从有序数组中删除重复项)

    [LeetCode] Remove Duplicates from Sorted Array 有序数组中去除重复项 描述 Given a sorted array nums, remove the d ...

  9. [LeetCode] 80. Remove Duplicates from Sorted Array II 有序数组中去除重复项之二

    Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twic ...

随机推荐

  1. robot framework环境搭建

    来源:http://www.cnblogs.com/puresoul/p/3854963.html[转] 一. robot framework环境搭建: 官网:http://robotframewor ...

  2. linux shell编程-bash的奇技淫巧

    本文主要讲bash脚本中容易出错和很少用但是用起来有意想不到效果的部分. 循环: 正常的for循环: for i in a b c 1 2 3; do echo "$i" done ...

  3. 网页中嵌入百度地图报错:The request has been blocked,the content must served over Https

    网页中嵌入百度地图 1.进入百度地图开发平台:http://lbsyun.baidu.com/index.php?title=jspopular 2.获取密钥:http://lbsyun.baidu. ...

  4. MySQL基础语法------增删改查

    1.增 1.1建立数据库 create database test2; 格式:create database <数据库名> 1.2建表 create table student( sno ...

  5. python 标准库 -- subprocess

    subprocess 主要功能室执行外部的命令和程序 一个进程可 fork 一个子进程, 并让这个子进程 exec 另外一个程序. 在 python 中, 可以通过标准库中的 subprocess 包 ...

  6. 微服务架构:基于微服务和Docker容器技术的PaaS云平台架构设计(微服务架构实施原理)

    版权声明:本文为博主原创文章,转载请注明出处,欢迎交流学习! 基于微服务架构和Docker容器技术的PaaS云平台建设目标是给我们的开发人员提供一套服务快速开发.部署.运维管理.持续开发持续集成的流程 ...

  7. js函数一些小的知识点

    var scope="123"; function aa(){ console.log(scope);//undefind var scope="234"; c ...

  8. 使用Iterator的方式也可以顺利删除和遍历

    使用Iterator的方式也可以顺利删除和遍历 eg: public void iteratorRemove() { List<Student> students = this.getSt ...

  9. win7中python3.4下安装scrapy爬虫框架(亲测可用)

    貌似最新的scrapy已经支持python3,但是错误挺多的,以下为在win7中的安装步骤: 1.首先需要安装Scrapy的依赖包,包括parsel, w3lib, cryptography, pyO ...

  10. 关于ZendStudio 10.5的破解 包括mac

    一. 下载ZendStudio 10.5 首先下载ZendStudio 10.5 我使用的是mac版 下载地址是: http://downloads.zend.com/studio-eclipse/1 ...