【发布时间】:2017-03-31 20:17:44
【问题描述】:
我正在开发一个小型 API,我想使用 HTTP PATCH REQUEST 更新数据,而不使用一堆 if 语句。我正在尝试仅用更改的数据填充传出数据对象。
update() {
let prop1 = hasBeenChanged.prop1 ? changedData.prop1 : null;
// ...
let propN = hasBeenChanged.propN ? changedData.propN : null;
let data: ISomething = {
// something like --> property != null ? property: property.value : nothing
}
}
有没有办法动态创建数据对象?
【问题讨论】:
标签: javascript typescript javascript-objects