基本上我有兩個數組,我用它來配置按鈕。第一個數組,它定義了應按順序顯示的按鈕數量。buttonGroups: [ 0, 2 ]另一個關于實際按鈕的對象數組。 buttons = [ { buttonLabel: 'label1', cond1: true, cond2: false }, { buttonLabel: 'label2', cond1: true, cond2: false }, { buttonLabel: 'label3', cond1: false, cond2: true }];是buttonGroups配置數組。如果它只有[0, 1]那么前兩個按鈕將存在。如果buttonGroups只有我們應該在數組中[0, 3]存在第一個和第三個按鈕。buttons這是我嘗試過的buttonGroups.map((payload1, index1) => { buttons .map((payload2, index2) => { if(index1 === index2){ //Display Here only the matched index from ButtonGroups console.log(payload2) } })})這是第一個索引按鈕數組。如何獲得匹配的數組按鈕?
比較兩個數組并過濾它們 javascript
蠱毒傳說
2022-05-26 14:37:21