JS Delete Array repeating elements method

Source: Internet
Author: User

<script language= "Web Effects" >
<!--
function each (list, fun) {
for (var i = 0, len = list.length i < len; i++) {Fun (list[i], i);}
};

var arr = [1,2,3,4,1,3]

var t
Each (Arr.sort (), function (o,i) {
if (i>0 && o = = t) {alert ("same:" + O);}
Alert (t)
t = o;
})

-->
</script>

Method Three

function Filterarray (Str,array) {//This function is to filter the duplicated elements in the array, does not allow the insertion of NULL values, functions return an array
var isnull = false;
if (str = = "" | | str = NULL | | str = = ' undefined ') {
IsNull = true;
}
var newnum = 0;
var newarray = [];
var num = array.length;
if (num = 0) {
if (!isnull) {
Newarray[num] = str;
}
}else{
for (Var m=0;m < num;m++) {
if (str = = Array[m]) {
Break
}else{
newarray[newnum++] = array[m];
}
}
if (!isnull) {
newarray[newnum++] = str;
}
}
return newarray;
}

Other methods

<script>
Alert ("1,11,1.11,1111,111,11,1,1.11". Match (/(d+ (?:. d+)?) (?!. *,)/g))
</script>

<script>
Alert ("123450,0,1,2,5,3,2,12,4,1,1,123450". Match (/(d+) (?!. *, (, |$))/ig)
</script>


<script>
Alert ("123450,0,1,2,5,3,2,12,4,1,1,123450". Match (/(d+) (?!) (?:, [^,]+) *, (?:, |$))/ig))
</script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.