Home > Web Front-end > JS Tutorial > javascript returns unique elements in an array_javascript tips

javascript returns unique elements in an array_javascript tips

WBOY
Release: 2016-05-16 18:39:41
Original
1363 people have browsed it

这是实现结构伪类type-of-type的部分代码:


[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

觉得效果不高,向无忧高手求救。下面是客服果果的(好强大的正则替换啊):

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

abcdreamer 的实现(此实现能过滤非纯字符串数组里的重复,我比较喜欢):

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

哪位高手有更好的实现,请告诉我一声!
看来有些人不明白norepeat函数与unique函数的区别,norepeat是去除数组中重复的元素,如果数组中有两个a,则去除这两个,unique则会去除其中之一。下面是unique函数的实现:

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template