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

239
Views
¿Cómo se convirtió [len] en propiedad de arr, es decir (Number(arr[len]) en el siguiente código?

No puedo entender cómo (Number(arr[len]) está compuesto. [len] se convirtió en la propiedad de arr .

 function arrayMax(arr) { var len = arr.length, max = -Infinity; while (len--) { if (Number(arr[len]) > max) { max = Number(arr[len]); } } return max; };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Este es probablemente un intento de una forma súper eficiente de obtener el valor máximo en una matriz.

La variable len está mal nombrada con toda justicia. Debería haber sido etiquetado como índice.

 function arrayMax(arr) { var index = arr.length, max = -Infinity; while (index--) { if (Number(arr[index]) > max) { max = Number(arr[index]); } } return max; };

Y arr[index] obtiene el valor en el índice especificado.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#access_an_array_item_by_its_index

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!