Why using const in a for loop does not throw an error
P粉244155277
P粉244155277 2023-09-08 16:14:20
0
1
354

const todolist= [];
let todolisthtml = '';
     for(let i =0;i<todolist.length;i++){
          const todo = todolist[i];
          const html = <p>`${todo}`</p>;
          todolisthtml += html;
      }

Here, whenever we iterate through the loop, we are reassigning the variable todo, which should cause an error because we declared it using "const", but it works smoothly

P粉244155277
P粉244155277

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!