How to get the index in a each loop in Jade

Maybe sometime you need to have an index in a each loop in Jade, like the for loop. It’s quite simple get the index in a each loop in Jade, take a look:

Get the index in a each loop in Jade

Add index as secondary parameter

each item, index in array li 
  Index: #{index} Object: #{item}

Remember index starts in 0.

Leave a comment with your suggestions or doubts 🙂

David Burgos

Read more posts by this author.