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

165
Views
Verificar con Array [índice] varias veces frente a configurarlo como una variable y usarlo - JAVASCRIPT/NODE.JS

Tengo un montón de declaraciones if y configurando/agregando diferentes accesorios en mi matriz. Mi código javascript es como;

 for(var key in animals){ if(animals[key].eyesColor == "blue"){ animals[key].hairColor = "yellow" ... ... } }

Como verifiqué, estoy usando 78 veces animals[key].props Y mi matriz probablemente contiene más de 1000 elementos.

¿Debo establecer animal[key] en una variable y luego volver a establecer esta variable en mi matriz de muestra al final de mi código? ¿De esta manera puedo mejorar el rendimiento?

 for(var key in animals){ let animal = animals[key] if(animal.eyesColor == "blue"){ animal.hairColor = "yellow" ... ... } animals[key] = animal }
about 4 years ago · Juan Pablo Isaza
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!