js
pretend丿1
这个作者很懒,什么都没留下…
展开
-
数组去重
Array.prototype.unique = function(){ let temp = {} let arr = [] let len = this.length // 谁调用的this就指向谁 arr for (var i = 0; i < len; i++) { if(!temp[this[i]]){ temp[this[i]] = ‘anything’ arr.push(th...原创 2019-06-12 21:44:28 · 121 阅读 · 0 评论 -
字符串去重
function strUnique(target){ let str = ‘’ let arr = target.split(’’) arr = new Set(arr) arr = […arr] str =arr.join(’’) return str }原创 2019-06-12 23:40:53 · 205 阅读 · 0 评论