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

388
Views
Does JavaScript object store keys (number) in sorted order by default?

Considering the below code snippet, obj[arr[i]] = arr[i] storing key,values in accending sorted order by default.

 var arr = [100,2,55,4,3,5,2,66]
    var obj = {}
    for(let i in arr)
      {
        obj[arr[i]] = arr[i] 
      }
    
    console.log(Object.values(obj)) // output : [2, 3, 4, 5, 55, 66, 100]

I am trying to know the reason behind it, is it the default nature of objects in javascript?

if am not wrong this would be the simplest O(n) time complexity sorting algorithm if the array is non-duplicate numbers

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!