博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
唯一数组值
阅读量:2512 次
发布时间:2019-05-11

本文共 1042 字,大约阅读时间需要 3 分钟。

When you look at any programming language, you see missing features that you find puzzling because the use case seems so common.  One such case is retrieving unique values from an array with JavaScript. Years ago I mentioned an using objects instead of arrays, but that's not always an option and doesn't match every use case.

当您使用任何一种编程语言时,都会发现缺少的功能,这些功能令人困惑,因为用例似乎很常见。 一种这样的情况是使用JavaScript从数组中检索唯一值。 几年前,我提到了使用对象而不是数组的 ,但这并不总是一种选择,并且并不适合每个用例。

Want to retrieve a unique array of values from an array that may include duplicate values?  You can use new JavaScript spread operator with Set to get an array of unique values:

是否想从可能包含重复值的数组中检索值的唯一数组? 您可以将新JavaScript Spread运算符与Set一起使用,以获取唯一值数组:

var j = [...new Set([1, 2, 3, 3])]>> [1, 2, 3]

Getting unique array values is another .  And don't forget you can

获得唯一的数组值是另一种 。 并且不要忘记,您可以

There's no better feeling than being able to remove a library to complete a task that should be native to the language.  This trick brings us one step closer to that!

没有什么比删除库来完成该语言固有的任务更好的感觉了。 这个技巧使我们更接近了这一步!

翻译自:

转载地址:http://efvwd.baihongyu.com/

你可能感兴趣的文章
智能提示
查看>>
[JavaScript] 弹出编辑框
查看>>
一个消息队列MQ调试工具
查看>>
springmvc 访问时找不到配置文件
查看>>
采访吴岳师兄有感 by 王宇飞
查看>>
LVS简略介绍
查看>>
hdu 1021 Fibonacci Again
查看>>
JVM架构_XmnXmsXmxXss有什么区别:转
查看>>
PHPExcel 使用心得
查看>>
洛谷 P3374 【模板】树状数组 1(单点加,区间和)
查看>>
verilog 代码编写小记
查看>>
PyQT的安装和配置
查看>>
从 docker 到 runC
查看>>
python基础学习笔记(十一)
查看>>
守护进程
查看>>
第十二周作业
查看>>
php数组
查看>>
Linux 防火墙
查看>>
android 自定义图片圆形进度条
查看>>
互联网金融P2P主业务场景自动化测试
查看>>