数组的处理

//JavaScript判断数组是否包含指定元素的方法
Array.prototype.contains = function(needle) {
	for(i in this) {
		if(this[i] == needle) return true;
	}
	return false;
}
//	求两个数组的不相同元素
function ArrydifferentE(a, b) {
	var  c  =   [];
	var  tmp  =  a.concat(b);
	var  o  =   {};
	for (var  i  =  0;  i  <  tmp.length;  i ++) (tmp[i]  in  o)  ?  o[tmp[i]] ++  :  o[tmp[i]]  =  1;
	for (x  in  o) 
		if (o[x]  ==  1)  c.push(x);
	return(c);
}

  

posted @ 2017-08-24 19:15  RAINHAN  阅读(131)  评论(0编辑  收藏  举报