判断两个数组是否相等
function arrayEqual(arr1, arr2) {
if (arr1 === arr2) return true;
if (arr1.length != arr2.length) return false;
for (var i = 0; i < arr1.length; ++i) {
if (arr1[i] !== arr2[i]) return false;
}
return true;
}
数字每隔三位添加一个逗号分隔符
/*
*
* @desc 为数字每隔三个添加分隔符
* @param number
* @return str
*/
function addComma(num,separator){
let str = num.toString();
let arr = [];
arr.length = str.length + parseInt(str.length/3);
strArr = str.split("");
let curIndex = strArr.length-1;
for(let i = arr.length-1; i>=0; i--){
if((arr.length-i)%4 == 0){
arr[i] = separator;
}else{
arr[i] = strArr[curIndex--];
}
}
return arr.join("");
}