Jus*_*tin 1 javascript ecmascript-6
是否有重写以下ES6 JavaScript不需要临时存储变量data?
const data = {};
if(error) {
    data.error = error;
} else {
    data.response = 'some response here';
}
res.json(200, data);
我想能够将对象内联到res.json():
res.json(200, {
    // inline logic that is identical to above
});
你可以使用三元运算符
res.json(200, error ? {error} : {response: 'some response here'});
| 归档时间: | 
 | 
| 查看次数: | 121 次 | 
| 最近记录: |