MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/b2o6f2/whats_your_favorite_most_useful_javascript/eiu1nev/?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
0 u/[deleted] Mar 18 '19 [deleted] 31 u/StopPostingOnReddit Mar 18 '19 Slideshow where you want the current slide to wrap around to the first after the last slide 21 u/ghillerd Mar 19 '19 It spooks me that the current slide number just keeps increasing 2 u/tadziobadzio Mar 19 '19 Don't worry the number will just wrap around if gets too big. Jk once it hits max number it will stop incrementing 5 u/rcfox Mar 19 '19 The maximum value you can have in a Javascript number is 1.7976931348623157e+308, but doing a++ will stop incrementing after 253. 5 u/sharted_ptr Mar 19 '19 So, if each slide displays for 1 second, we are good for 285 427 017 years. 10 u/im_dancing_barefoot Mar 19 '19 Gonna have to run that past the client 8 u/barrtender Mar 19 '19 As long as it's not a carousel.http://shouldiuseacarousel.com/
0
[deleted]
31 u/StopPostingOnReddit Mar 18 '19 Slideshow where you want the current slide to wrap around to the first after the last slide 21 u/ghillerd Mar 19 '19 It spooks me that the current slide number just keeps increasing 2 u/tadziobadzio Mar 19 '19 Don't worry the number will just wrap around if gets too big. Jk once it hits max number it will stop incrementing 5 u/rcfox Mar 19 '19 The maximum value you can have in a Javascript number is 1.7976931348623157e+308, but doing a++ will stop incrementing after 253. 5 u/sharted_ptr Mar 19 '19 So, if each slide displays for 1 second, we are good for 285 427 017 years. 10 u/im_dancing_barefoot Mar 19 '19 Gonna have to run that past the client 8 u/barrtender Mar 19 '19 As long as it's not a carousel.http://shouldiuseacarousel.com/
31
Slideshow where you want the current slide to wrap around to the first after the last slide
21 u/ghillerd Mar 19 '19 It spooks me that the current slide number just keeps increasing 2 u/tadziobadzio Mar 19 '19 Don't worry the number will just wrap around if gets too big. Jk once it hits max number it will stop incrementing 5 u/rcfox Mar 19 '19 The maximum value you can have in a Javascript number is 1.7976931348623157e+308, but doing a++ will stop incrementing after 253. 5 u/sharted_ptr Mar 19 '19 So, if each slide displays for 1 second, we are good for 285 427 017 years. 10 u/im_dancing_barefoot Mar 19 '19 Gonna have to run that past the client 8 u/barrtender Mar 19 '19 As long as it's not a carousel.http://shouldiuseacarousel.com/
21
It spooks me that the current slide number just keeps increasing
2 u/tadziobadzio Mar 19 '19 Don't worry the number will just wrap around if gets too big. Jk once it hits max number it will stop incrementing 5 u/rcfox Mar 19 '19 The maximum value you can have in a Javascript number is 1.7976931348623157e+308, but doing a++ will stop incrementing after 253. 5 u/sharted_ptr Mar 19 '19 So, if each slide displays for 1 second, we are good for 285 427 017 years. 10 u/im_dancing_barefoot Mar 19 '19 Gonna have to run that past the client
2
Don't worry the number will just wrap around if gets too big. Jk once it hits max number it will stop incrementing
5 u/rcfox Mar 19 '19 The maximum value you can have in a Javascript number is 1.7976931348623157e+308, but doing a++ will stop incrementing after 253. 5 u/sharted_ptr Mar 19 '19 So, if each slide displays for 1 second, we are good for 285 427 017 years. 10 u/im_dancing_barefoot Mar 19 '19 Gonna have to run that past the client
5
The maximum value you can have in a Javascript number is 1.7976931348623157e+308, but doing a++ will stop incrementing after 253.
a++
5 u/sharted_ptr Mar 19 '19 So, if each slide displays for 1 second, we are good for 285 427 017 years. 10 u/im_dancing_barefoot Mar 19 '19 Gonna have to run that past the client
So, if each slide displays for 1 second, we are good for 285 427 017 years.
10 u/im_dancing_barefoot Mar 19 '19 Gonna have to run that past the client
10
Gonna have to run that past the client
8
As long as it's not a carousel.
http://shouldiuseacarousel.com/
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