Así que tuve este tipo de valor constante
const testingObjArr = [ { asdasdasdasdds:"testing 123" }, { bcdefghasdkl:"testing 456" }, { asdklqwoepskalx:"testing 678" }, ]Solo quiero obtener el valor e insertarlo en una nueva matriz como esta
["testing 123", "testing 456", "testing 678"]Intenté usar Object.values y formas similares, pero siempre devolví los mismos valores cuando lo registré.
este es el ultimo metodo que use
console.log( "testing objs",Object.values(obj).map(i => i).flat())También uso este bucle para obtener los valores.
const testingObjArrLength = Object.keys(testingObjArr).length; const finalDatas = []; for(let x=0; x<testingObjArrLength; x++) { const datas = Object.values(testingObjArr)[x] finalDatas.push(datas); } console.log("finaldatas", finalDatas);Estos son los resultados en el registro de la consola
¿alguien puede darme un consejo? agradezco que si no lo etiqueté con duplicado, porque he estado buscando las soluciones
Puede tomar Array#flatMap con Object.values como devolución de llamada.
const data = [{ asdasdasdasdds: "testing 123" }, { bcdefghasdkl: "testing 456" }, { asdklqwoepskalx: "testing 678" }], values = data.flatMap(Object.values); console.log(values);