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

142
Views
Object.defineProperty doesn't return Object.entries

Why both object returns in console but only the first has entries?

let obj1 = {
  1: 1,
  2: 2
}

let obj2 = {}

for (let i = 0; i < 2; i++) {
  Object.defineProperty(obj2, i, {
    value: i
  })
}

console.log(obj1);
console.log(Object.entries(obj1));

console.log(obj2);
console.log(Object.entries(obj2));

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

0

Provide the option enumerable: true so that the new properties can be enumerated.

let obj1 = {
  1: 1,
  2: 2
}

let obj2 = {}

for (let i = 0; i < 2; i++) {
  Object.defineProperty(obj2, i, {
    value: i,
    enumerable: true,
  })
}

console.log(obj1);
console.log(Object.entries(obj1));

console.log(obj2);
console.log(Object.entries(obj2));

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!