Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
Array.find() da el error "TypeError: theArray.find(...) no está definido"

Recibo TypeError: theArray.find(...) is undefined a partir de un código que es, en esencia, similar a este:

 if (!Array.isArray(theArray)) console.error("WARNING! theArray is not an array: ", theArray); console.log(theArray.find((element) => element).someProperty);

No recibo el mensaje de error ¡ADVERTENCIA! theArray no es una matriz , pero recibo el error theArray.find(...) is undefined

El mensaje de error no dice que theArray no está definido, este es un mensaje de error que yo haría excepto cuando theArray no es del tipo matriz.

Dentro de la función de matriz habría una lógica más compleja, pero la simplifiqué para centrarme en el problema de Array.find(). La variable theArray es una matriz de objetos complejos, con muchas propiedades.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Array.find devolverá undefined cuando no encuentre un resultado.

El mensaje de error significa que la función find() devolvió undefined, entonces someProperty no se puede encontrar en undefined .

Ejemplo para aclaración:

 let testArray = [{a: 3}, {a: 4}, {a: 5}]; let notArray = 5;

testArray.find((item) => item.a === 3); resultará Object { a: 3 }
tetArray.find((item) => item.a === 3); resultará un Uncaught ReferenceError: tetArray is not defined
notArray.find((item) => item.a === 3); dará como resultado Uncaught TypeError: notArray.find is not a function
testArray.find((item) => item.a === 7).a; dará como resultado Uncaught TypeError: testArray.find(...) is undefined

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!