0
我想讓數組(從)變成像(到)。爲了在相同排列值不包括「qtty」我用:如何使用對象和嵌套數組過濾數組
_.isEqual(_.omit(val, 'qtty'), _.omit(value2, 'qtty'))
從http://underscorejs.org/#isEqual它給了正確的結果,但我沒能得到證明波紋管的最終結果。
From =
0 {itemId: "121", qtty: 1, subitem: [], combo: [{comboId: 201, setId: 29}, {comboId: 201, setId: 28}], addon: []}
1 {itemId: "121", qtty: 1, subitem: [], combo: [{comboId: 201, setId: 29}, {comboId: 201, setId: 28}], addon: []}
2 {itemId: "121", qtty: 1, subitem: [{subitemId: 72, state: 1}], combo: [{comboId: 201, setId: 29}, {comboId: 201, setId: 28}], addon: []}
3 {itemId: "141", qtty: 1, subitem: [], combo: [{comboId: 201, setId: 26}], addon: []}
4 {itemId: "347", qtty: 1, subitem: [], combo: [], addon: []}
5 {itemId: "347", qtty: 1, subitem: [], combo: [], addon: []}
To =
0 {itemId: "121", qtty: 2, subitem: [], combo: [{comboId: 201, setId: 29}, {comboId: 201, setId: 28}], addon: []}
1 {itemId: "121", qtty: 1, subitem: [{subitemId: 72, state: 1}], combo: [{comboId: 201, setId: 29}, {comboId: 201, setId: 28}], addon: []}
2 {itemId: "141", qtty: 1, subitem: [], combo: [{comboId: 201, setId: 26}], addon: []}
3 {itemId: "347", qtty: 2, subitem: [], combo: [], addon: []}