Inside Express/EJS templates, what is cleanest way to loop through an array?

前端 未结 1 842
面向向阳花
面向向阳花 2020-12-29 22:48

I have an Express.js app set up using EJS templates. I successfully looped through an array with classic JS syntax:

<% for (var i = 0; i < myArray.leng         


        
相关标签:
1条回答
  • 2020-12-29 23:36

    You can use forEach method

    myArray.forEach(function(el, index) {
        // el - current element, i - index
    });
    
    0 讨论(0)
提交回复
热议问题