- Joined
- Dec 15, 2009
- Messages
- 1,387
- Reaction score
- 236
You must be registered to see links
how can I only retrieve an element from var arrays one at a time in an arranged number?
no math.random pls
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature currently requires accessing the site using the built-in Safari browser.
How can make it infinite loop? Haven't check the codes thoUltimately the best way for you to iterate over the array depends on what kind of content you have in there - e.g. whether they're meant to repeat or be used only once, but here's one approach assuming messages are something that appear at random times and do get shown only once.
You must be registered to see links
Just code that damn ring buffer yourself, it'll do good for you.
For an extremely naive solution though that will work in 10 seconds (that you should not consider a proper implementation and never quote on me telling you to write it like that), on every iteration just shift out the first element from the array and when you're done with it just push it back to the end of the array. (like that:You must be registered to see links)
Let me repeat, it's a bad solution in the general case because it has has terrible performance implications AND it's extremely vulnerable to concurrency issues should it be implemented on a platform that supports concurrent executions.