Javascript Best Practices — Use For In Loops
1 min readSep 28, 2020
For loops can be shortened and cleaned. Let’s see an example:
Long-form:
const friends = ['amar', 'akbar', 'anthony'];for (let i = 0; i < friends.length; i++){ console.log(friends[i]);}
Short / clean form:
const friends = ['amar', 'akbar', 'anthony'];for (const friend in friends){ console.log(friend);}
Read more: https://blog.nordible.com/Javascript-Best-Practices-Use-For-In-Loops/