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

266
Views
In the for loop, the constant variable will be declared as many time as the loop runs. Why its not an error?

for(let i =0; i<10;i++){
    const a = i;               
    console.log(a);
}

const b = 5;
const b = 10;   

for(const i =0; i<10;i++){
    const a = i;                
    console.log(a);
} 

enter code here

In above code b is declared twice so system is giving an error. Uncaught SyntaxError: Identifier 'b' has already been declared

In the for loop, the constant variable will be declared as many time as the loop runs. Why its not an error?

In the second loop why the const i throwing an error? Is const i in the for loop initialisation have a different scope?

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!