15 ms·
I've also taken to: Array.from({ length: 5 }).forEach(...) But I'm not sure what you gain from that compared to just wrapping a for loop in a function. Yo
by ljm 8y ago
I've also taken to:
Array.from({ length: 5 }).forEach(...)
But I'm not sure what you gain from that compared to just wrapping a for loop in a function. You still don't get ranges the way you do in, say Ruby:
('a'..'z').each {|letter| puts letter }
- klardotsh 8y agoYeah, I mostly work in Python, where ranging and slicing is amazing. JS has a lot to catch up on in that regard.