Ganxiaozhe 2020-10-02 16:35:20

混合数组深度去重,源自项目 gQuery.js

function unique(arr,typ){
	let j = {};
	if( typ=='node' ){
		return arr.filter(function(item, index, arr) {
			return arr.indexOf(item, 0) === index;
		});
	}

	arr.forEach(function(v){
		let vtyp = typeof v,vv=v;
		if(vtyp==='object'){v = JSON.stringify(v);}
		j[v + '::' + vtyp] = vv;
	});
	return Object.keys(j).map(function(v){return j[v];});
}

评论

trang chủ - Wiki
Copyright © 2011-2024 iteam. Current version is 2.137.3. UTC+08:00, 2024-11-28 13:46
浙ICP备14020137号-1 $bản đồ khách truy cập$