¿Cómo filtro una matriz comprobando si una matriz aparece en la matriz?
cryptoData: Array(100) 0: {CoinInfo: {…}, RAW: {…}, DISPLAY: {…}}
Estoy tratando de verificar si cryptoData (Array) contiene la matriz DISPLAY y si no contiene DISPLAY, elimínelo de la matriz cryptoData y configure filterArray solo con los elementos que contienen DISPLAY Array.
Mi intento:
var filterdArray = cryptoData.filter(function (el) { return cryptoData[el] === 'DISPLAY'; }); this.setState({ cryptos: filterdArray, refreshing: false, });Como el valor es un objeto, puede usar hasOwnProperty para verificar si el objeto tiene una propiedad.
var filterdArray = cryptoData.filter(function (el) { return el.hasOwnProperty('DISPLAY'); }); this.setState({ cryptos: filterdArray, refreshing: false, });