【前端问题精选】怎样去除js键的引号
function duplicates(arr) { var obj = {};
var newArr = [];
for (var i in arr){
if(obj[arr[i]]){
obj[arr[i]]++;
}
else{
obj[arr[i]]=1;
}
}
Object.keys(obj).forEach(function(key){
if(obj[key]==1){
newArr.push(key);
}
});
console.log(newArr);
var str = newArr.join('');
console.log(str);
var newarr2 = [];
newarr2 = str.split('');
console.log(newarr2);
}
duplicates([1,2,3,3,6,6,5]);
回答:
const duplicates = arr => arr.sort().filter((a, i) => a !== arr[i-1] && a !== arr[i+1])duplicates([1,2,3,3,6,6,5])
回答:
字符串转成number?
以上是 【前端问题精选】怎样去除js键的引号 的全部内容, 来源链接: utcz.com/a/133199.html