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