我有一个名为collection
. 该数组包含大量长度为 12 的数组。后一个数组的每个项目都具有源 ID [0] 和目标 ID [1](源和目标对是唯一的,但相同的源ID 可以分配给不同的目标 ID)。
给定源 ID 和目标 ID 后,我需要在数组中找到具有给定 ID 的项目并操作其值。
如果这有助于找到解决方案,则存在 jQuery。
提前致谢!
var collection = [
[
136898,
162582,
"8X1ABG\1",
"lorem ipsum",
true,
"FULL",
true,
"FULL",
"8X1ABG\0",
"dolor sit",
false,
"SIMILAR"
],
[
136898,
163462,
"8X1ABG\1",
"lorem ipsum",
true,
"FULL",
true,
"FULL",
"8X1ABG\0",
"dolor sit",
false,
"SIMILAR"
],
[
136578,
161873,
"8X1A1G\2",
"lorem ipsum",
true,
"FULL",
true,
"FULL",
"8X1A1G\0",
"dolor sit",
false,
"SIMILAR"
],
[
136432,
162280,
"8X1ABC\1",
"lorem ipsum",
true,
"FULL",
true,
"FULL",
"8X1ABC\0",
"dolor sit",
false,
"SIMILAR"
]]
// TODO: find the unique item in collection array with the following source
// and target ID
var sourceId = 136898;
var targetId = 163462;
// TODO: update some values of the identified item inside collection