以下函数接受与“user”链接的两个数字,并根据该数字计算id号。我一直试图让它尽可能干净,并希望得到一些关于如何提高效率的建议。
function getidnumber(num, ts) {
num = num.substr(4, 4);
ts = ((ts == undefined) ? "3452" : (ts));
var _local5 = "";
var _local1 = 0;
while (_local1 < num.length) {
var _local4 = Number(num.substr(_local1, 1));
var _local3 = Number(ts.substr(_local1, 1));
var _local2 = String(_local4 + _local3);
_local5 = _local5 + _local2.substr(_local2.length - 1);
_local1++;
}
return("@user" + _local5);
};
答案 0 :(得分:1)
可能是拉链?
function zip() {
var args = [].slice.call(arguments);
var shortest = args.length==0 ? [] : args.reduce(function(a,b){
return a.length<b.length ? a : b
});
return shortest.map(function(_,i){
return args.map(function(array){return array[i]})
});
}