function unique(dislodgeArr) { var ret = [] var hash = {} var datasource = new Array(); var array= dislodgeArr.split(',') if(array.length > 0){ for(var d in array){ var item = array[d]; datasource.push(item) } } for (var i = 0; i < datasource.length; i++) { var item = datasource[i] var key = typeof(item) + item if (hash[key] !== 1) { ret.push(item) hash[key] = 1 } } return ret }
修改的