To make an array uniqued, we can use Set() from Javascript.

const ary = ["a", "b", "c", "a", "d", "c"];
console.log(new Set(ary));

We can see that all the duplicated value have been removed,  now the only thing we need to do is convert Set to Array.

So we have Array.from:

const ary = ["a", "b", "c", "a", "d", "c"];
const res = uniqueArray(ary);
console.log(res); function uniqueArray(ary) {
return Array.from(new Set(ary));
}

Or even shorter:

const ary = ["a", "b", "c", "a", "d", "c"];
const res = uniqueArray(ary);
console.log(res); function uniqueArray(ary) {
return [...new Set(ary)];
}

Whichever you prefer.

最新文章

  1. Hibernate SQL方言 (hibernate.dialect) Spring配置文件applicationContext.xml
  2. MVC中Action的执行过程
  3. 转:MVC单表多按钮提交
  4. hibernate manytoone中的lazy EAGER
  5. Hive on Spark运行环境搭建
  6. Sql Server 远程过程调用失败
  7. 【LeetCode练习题】First Missing Positive
  8. 定向爬虫之爬一爬各个学校新闻的认识(【1】对Url的认识)
  9. JavaScript变量存储浅析
  10. testng及JMeter使用之初体验
  11. Taurus.MVC 2.3 开源发布:增强属性Require验证功能,自带WebAPI文档生成功能
  12. python3 - 文本读音器
  13. Linux cached过高问题
  14. 安卓开发_深入理解Content Provider
  15. leecode第一百四十二题(环形链表II)
  16. JS面试典型常见问题与解答
  17. office 2007,SQL Server 2008,VS2010安装步骤
  18. Hadoop框架
  19. Java中Date与String的相互转换
  20. Java的基本类型

热门文章

  1. 扩展欧几里得(ex_gcd),中国剩余定理(CRT)讲解 有代码
  2. js 数组遍历
  3. 使序列有序的最少交换次数(minimum swaps)
  4. Strlcpy和strlcat——一致的、安全的字符串拷贝和串接函数【转】
  5. 链表各种操作及其实现方法(c实现)
  6. DropZone图片上传控件的使用
  7. python中函数和生成器的运行原理
  8. 解决svn 异常:svn: E155027: Tree conflict can only be resolved to working state; {0} not resolved
  9. OutputDebugString方便格式化WIN32封装
  10. (22)C#windows打包部署