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

136
Views
Why do for in and for of loops not display a complex type properly?

I am Learning JavaScript and I would like to know why I am not able to print objects within for in and for of loops whereas I can if not inside a loop (see below):

let arr = [{abc: '123'}, {xyz: '321'}];
let obj = {obj1:{abc: '123'}, obj2:{xyz: '321'}};

for(let x of arr)
{
  console.log(`${x}`);
}
for(let x of arr)
{
  console.log(`${x}`);
}

console.log(arr[0]); // this works
console.log(obj.obj1); // this works

Could someone explain why this is please, it keeps printing [object object] and I have no idea why. I thought it should print the entire object and its contents

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!