//使用三元运算符
var code1, code2
code1 = received_client_count != 0 ? 0 : 1
code2 = new Date().getTime() - timestamp < 360000 ? code1 : 2
res.push({
name,
code: code2
});
//不使用三元运算符
if (received_client_count != 0) {
if (new Date().getTime() - timestamp < 360000) {
res.push({
name,
code: 0
});
} else {
res.push({
name,
code: 2
});
}
} else {
if (new Date().getTime() - timestamp < 360000) {
res.push({
name,
code: 1
});
} else {
res.push({
name,
code: 2
});
}
}