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

211
Views
¿Por qué hay una diferencia en la complejidad del tiempo en las funciones de los objetos y las funciones independientes?

Intenté comparar dos funciones que realizan la misma tarea:

 Number.prototype.getReverse = function() { let reverseNum = 0 let num = this while(num > 0) { reverseNum = (10 * reverseNum) + (num % 10) num = Math.floor(num / 10) } return reverseNum } const numb = 1234567 console.time() console.log(numb.getReverse()) console.timeEnd() function getReverseNum(num) { let reverseNum = 0 while (num > 0) { reverseNum = (10 * reverseNum) + (num % 10) num = Math.floor(num / 10) } return reverseNum } console.time() console.log(getReverseNum(numb)) console.timeEnd()

El prototipo del objeto Number tomó mucho más tiempo:

 7654321 default: 0.42ms 7654321 default: 0.109ms

Tenía curiosidad por saber si alguien podría saber por qué es esto. ¿Tiene que ver con la forma en que JavaScript accede a la función a través del objeto Número?

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!