Created
October 6, 2011 07:32
-
-
Save yangg/1266760 to your computer and use it in GitHub Desktop.
js正则匹配数组中不重复的元素
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr=["a","b","c","a","ba","bc"]; | |
alert(arr.join(",").match( /([^,]+)(?!.*,\1(,|$))/ig)); | |
Array.prototype.deleteEle=function(){ | |
var arr=this,o={},newArr=[],i; | |
for( i=0;i<arr.length;i++){ | |
if(typeof(o[arr[i]])==="undefined"){ | |
newArr[newArr.length]=arr[i] | |
} | |
} | |
return newArr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment