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

290
Views
`let` vs. `const` vs. nada en un bucle for-of

¿Cuál es la diferencia al hacer las siguientes tres construcciones en JavaScript:

 let dd = [ 1, 2, 3, 4, 5 ]; for(const item of dd) console.log(item); for(let item of dd) console.log(item); for( item of dd) console.log(item);

Parece que todos producen exactamente los mismos resultados, por lo que me pregunto si hay algunas diferencias sutiles entre ellos, especialmente cuando no hay ni let ni const , específicamente en el contexto de un bucle for – of .

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

0

Aquí hay algunos ejemplos que demuestran la diferencia:

 let dd = [1, 2, 3, 4, 5] // identically-named variable in the outer scope let item = -1 for (const item of dd) { console.log(item) // ok // console.log(++item) // can't re-assign - will throw if uncommented } console.log(item) // still -1, as `const` is block-scoped for (let item of dd) { console.log(item) // ok console.log(++item) // it's fine to re-assign 🎵 } console.log(item) // still -1, as `let` is block-scoped for (item of dd) {} console.log(item) // 5, as we've now re-assigned the variable in the outer scope // due to not using `const` or `let`

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!