我在javascript中有這個對象數組。當滿足某些條件時從這個對象數組中刪除對象
var array = [ { DATA_ID: 1,
DATA_NAME: 'XX',
DATA_GROUP: 2313,
CODE_NO: 1 },
{ DATA_ID: 6,
DATA_NAME: 'YY',
DATA_GROUP: 4213,
CODE_NO: 2 },
{ DATA_ID: 4,
DATA_NAME: 'ZZ',
DATA_GROUP: 2123,
CODE_NO: 3 },
{ DATA_ID: 8,
DATA_NAME: 'ZZ',
DATA_GROUP: 2123,
CODE_NO: 3 } ]
我想從對象的數組中刪除對象當地產CODE_NO === 3
結果會是這樣的;
[ { DATA_ID: 1,
DATA_NAME: 'XX',
DATA_GROUP: 2313,
CODE_NO: 1 },
{ DATA_ID: 6,
DATA_NAME: 'YY',
DATA_GROUP: 4213,
CODE_NO: 2 }
]
我使用Node.js的V6
向我們展示一些代碼,你試圖做到這一點? – aring
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter – Satpal