1

以下函数采用两个与“用户”相关联的数字,并据此计算一个 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);
};
4

1 回答 1

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]})
    });
}
于 2013-09-21T02:36:22.873 回答