javascript - javascript在推送时修改数组内对象的键值
问题描述
我正在尝试有条件地将对象推送到数组中......
并且当条件不满足时。我想将特定键的值更改为我要推送的对象。事情是这样的……
var temp = [];
status.forEach(status => {
event.forEach(event => {
if (status.id == event.status_id) {
temp.push({status_id : event.status_id, data : event})
} else if (event.action_id == null) {
temp.push({status_id : null, data : event})
//Now, what I want is to change the `status_id` of the `event` that I am about to push into the data array into NULL.
}
})
})
解决方案
推荐阅读
- php - 我将如何解决这些错误的问题?
- java - 如何将地图的地图转换为java中的列表
- directory - PowerShell - 列出以 A +(加号)开头的文件夹
- javascript - 关于为什么 lastIndexOf() 在这种情况下返回 -1 的非常简单的问题
- mysql - 一段时间后 MySQL 连接断开
- django - .delete(False) 中的 false 参数是什么
- simulation - 仅当 netlogo 中不存在链接时如何创建链接
- javascript - 为什么我的网页只向下滚动到底部时会出现延迟?
- python - mysqlconnection 在 Django 项目 M1 Mac 中不起作用
- javascript - 三个 js 抛出 _canvas is null 错误