一般做法

const unique = (arr) => {
const result = arr.reduce((acc, iter) => {
if(acc.indexOf(iter) === -1) {
acc.push(iter)
}
return acc
}, [])
return result
}

超前做法

const unique = (arr) => {
return [...new Set(arr)]
}

ScriptOJ-unique#89的更多相关文章

  1. 初学Python常见异常错误,总有一处你会遇到!

    初学Python常见错误 忘记写冒号 误用= 错误 缩紧 变量没有定义 中英文输入法导致的错误 不同数据类型的拼接 索引位置问题 使用字典中不存在的键 忘了括号 漏传参数 缺失依赖库 使用了pytho ...

  2. poj 1679 The Unique MST

    题目连接 http://poj.org/problem?id=1679 The Unique MST Description Given a connected undirected graph, t ...

  3. POJ 1679 The Unique MST 【判断最小生成树是否唯一】

    Description Given a connected undirected graph, tell if its minimum spanning tree is unique.  Defini ...

  4. Mysql的唯一性索引unique

    目录 唯一性索引unique影响: unique与primary key的区别: 存在唯一键冲突时,避免策略: insert ignore: replace into: insert on dupli ...

  5. 【二叉查找树】02不同的二叉查找树个数II【Unique Binary Search Trees II】

    提到二叉查找树,就得想到二叉查找树的递归定义, 左子树的节点值都小于根节点,右子树的节点值都大于根节点. +++++++++++++++++++++++++++++++++++++++++++++++ ...

  6. django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: admin

    创建了一个Django项目,且包含一个admin的app,但是在启动Django的是时候抛出了以下异常: Unhandled exception in thread started by <fu ...

  7. [LeetCode] Unique Substrings in Wraparound String 封装字符串中的独特子字符串

    Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz" ...

  8. [LeetCode] Minimum Unique Word Abbreviation 最短的独一无二的单词缩写

    A string such as "word" contains the following abbreviations: ["word", "1or ...

  9. [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  10. [LeetCode] Unique Word Abbreviation 独特的单词缩写

    An abbreviation of a word follows the form <first letter><number><last letter>. Be ...

随机推荐

  1. vue展示dicom文件,医疗系统。

    环境:vue.webpack.constone 资料来源及文件:https://github.com/GleasonBian/CornerstoneVueWADO 需要下载的模块:cornerston ...

  2. 完整安装always on 集群

    1.  四台已安装windows server 2008 r2 系统的虚拟机,配置如下: CPU : 1核 MEMORY : 2GB DISK : 40GB(未分区) NetAdapter : 2块 ...

  3. Idea的pom文件导入依赖包仍然报错

  4. django不定义model,直接执行自定义SQL

    如果不想定义model,直接执行自定义SQL,可如下操作: 1. 通过 connections获取db连接,如果是多个数据库,connections['dbName'] 来选择 2. 获取游标 cur ...

  5. ABAP-加密解密

    report zco_test. data:o_encryptor type ref to cl_hard_wired_encryptor, o_cx_encrypt_error type ref t ...

  6. 安装Caffe纪实

    第一章 引言 在ubuntu16.04安装caffe,几乎折腾了一个月终于成功;做一文章做纪要,以便日后查阅.总体得出的要点是:首先,每操作一步,必须知道如何检验操作的正确性;笔者的多次失误是因为配置 ...

  7. K8s之Etcd

    Etcd是一个开源的.高可用的.分布式的键值对数据存储系统,提供共享配置.服务的注册和发现.etcd与zookeeper相比算是轻量级系统,两者的一致性协议也一样,etcd的raft比zookeepe ...

  8. 无法在正在进行内容生成时调用 StartAt

    刚遇到一个奇怪的问题,用户点击创建销售订单的时候,弹出个 无法在正在进行内容生成时调用 StartAt,查看详细报错. ystem.InvalidOperationException: 无法在正在进行 ...

  9. oracle中文乱码的解决方法

    select userenv('language') from dual; NLS_LANG AMERICAN_AMERICA.AL32UTF8

  10. 亿级 ELK 日志平台构建部署实践

    本篇主要讲工作中的真实经历,我们怎么打造亿级日志平台,同时手把手教大家建立起这样一套亿级 ELK 系统.日志平台具体发展历程可以参考上篇 「从 ELK 到 EFK 演进」 废话不多说,老司机们座好了, ...