【发布时间】:2021-10-06 10:59:35
【问题描述】:
我们如何根据条件将键和值插入到现有的对象数组中,这可以使用 map 解决吗?在一行中? .谢谢
如果来自对象的 dealType 是 === PM Restructure,则插入新的键和值,如果 dealType Partner Location Submission 删除 AnnualRentProposed 和 AnnualRentCurrent。
感谢您的任何想法和帮助。
cashContribution : 3000, storeCashFlow : 4000,
#数据
this.data.object = [
{
"id": 196,
"name": "Partner Deal ",
"dealType": "Partner Location Submission",
"annualRentProposed": null,
"annualRentCurrent": null,
"firmTermRemaining": null,
"firmTermAdded": null,
"maxAvailableTerm": null,
"capitalContribution": null,
"createdOnString": "09/30/2021",
"fileName": null,
"serverFileName": null,
"size": null,
"absoluteUri": null,
"sentTo": null
},
{
"id": 197,
"name": "Buyout Deal Disposition",
"dealType": "Idle Buyout",
"annualRentProposed": null,
"annualRentCurrent": null,
"firmTermRemaining": null,
"firmTermAdded": null,
"maxAvailableTerm": null,
"capitalContribution": null,
"createdOnString": "09/30/2021",
"fileName": null,
"serverFileName": null,
"size": null,
"absoluteUri": null,
"sentTo": null
},
{
"id": 199,
"name": "Sublease Deal Disposition",
"dealType": "Idle Sublease",
"annualRentProposed": null,
"annualRentCurrent": null,
"firmTermRemaining": null,
"firmTermAdded": null,
"maxAvailableTerm": null,
"capitalContribution": null,
"createdOnString": "09/30/2021",
"fileName": null,
"serverFileName": null,
"size": null,
"absoluteUri": null,
"sentTo": null
},
{
"id": 203,
"name": "Disposition of Location #10532-S",
"dealType": "PM Restructure",
"annualRentProposed": null,
"annualRentCurrent": null,
"firmTermRemaining": null,
"firmTermAdded": null,
"maxAvailableTerm": null,
"capitalContribution": null,
"createdOnString": "10/01/2021",
"fileName": null,
"serverFileName": null,
"size": null,
"absoluteUri": null,
"sentTo": null
},
{
"id": 214,
"name": null,
"dealType": "Approval to Close",
"annualRentProposed": null,
"annualRentCurrent": null,
"firmTermRemaining": null,
"firmTermAdded": null,
"maxAvailableTerm": null,
"capitalContribution": null,
"createdOnString": "10/04/2021",
"fileName": null,
"serverFileName": null,
"size": null,
"absoluteUri": null,
"sentTo": null
},
{
"id": 215,
"name": "pmpm",
"dealType": "PM Restructure",
"annualRentProposed": null,
"annualRentCurrent": null,
"firmTermRemaining": null,
"firmTermAdded": null,
"maxAvailableTerm": null,
"capitalContribution": null,
"createdOnString": "10/05/2021",
"fileName": null,
"serverFileName": null,
"size": null,
"absoluteUri": null,
"sentTo": null
}
]
【问题讨论】:
标签: javascript angular typescript