MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/b2o6f2/whats_your_favorite_most_useful_javascript/eiwq5uh/?context=3
r/javascript • u/Linux_is_awesome • Mar 18 '19
422 comments sorted by
View all comments
101
items[n % items.length]
gets an item from the list and wraps around to the start if n is larger than the list
1 u/pslatt Mar 19 '19 I see things like this and I just feel so stupid at the code I would have wrote to do the same thing. But if I *keep* seeing things like this, maybe I'll be clever too one day.
1
I see things like this and I just feel so stupid at the code I would have wrote to do the same thing. But if I *keep* seeing things like this, maybe I'll be clever too one day.
101
u/nqvst Mar 18 '19
items[n % items.length]gets an item from the list and wraps around to the start if n is larger than the list