test() { var arr1 = ["A", "B", "C","C","A"]; var rq=arr1.filter(function(x,index,self){ return self.indexOf(x) == index; }) console.log(rq.toString()) var arr = ["A", "", "B", null, undefined, "C", " "]; var r = arr.filter(function(s) { return s && s.trim(); }); console.log(r) }
详情请见:http://www.cnblogs.com/cjx-work/p/8052865.html