Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3602904
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:48:19+00:00 2026-05-18T20:48:19+00:00

Is it possible to do the following using javascript/jquery? using setInterval with an array

  • 0

Is it possible to do the following using javascript/jquery?

using setInterval with an array of function names, if the array only has 1 function, it should do the following if the user opens the webpage at 10:00:00

function 1 - 10:00:00
function 1 - 10:00:01
function 1 - 10:00:02
function 1 - 10:00:03
function 1 - 10:00:04

then if the user clicks another button, a new function name gets added to the array, which ends up doing the following:

function 1 - 10:00:05
function 2 - 10:00:06
function 1 - 10:00:07
function 2 - 10:00:08
function 1 - 10:00:09
function 2 - 10:00:10
function 1 - 10:00:11
function 2 - 10:00:12
function 1 - 10:00:13

if the user clicks the button a 3rd time, a new function name gets added to the array, which ends up doing the following:

function 1 - 10:00:14
function 2 - 10:00:15
function 3 - 10:00:16
function 1 - 10:00:17
function 2 - 10:00:18
function 3 - 10:00:19
function 1 - 10:00:20
function 2 - 10:00:21
function 3 - 10:00:22

Is this possible? If it is possible, could someone please help me with some example script on how to get this to happen?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:48:19+00:00Added an answer on May 18, 2026 at 8:48 pm

    A simple mechanism:

    var intervalWork = (function() {
      var workers = [], wi = 0;
      var interval = setInterval(function() {
        if (!workers.length) return;
        workers[wi](wi);
        wi = (wi + 1) % workers.length;
      }, 60 * 1000);
    
      return function(w) {
        workers.push(w);
      };
    })();
    

    Then you have a function called “intervalWork” that allows a function to be added to the queue. One function per timer interval (60 seconds here) will be run. The functions are passed their index in the queue; that doesn’t seem generally interesting but it’d let you print out those messages.

    The function would be called like this:

    intervalWork(function(index) {
      // do interesting stuff
      console.log("Function " + index + " " + new Date());
    });
    

    Or you could call it and pass the name of an already-defined function:

    intervalWork(someRandomFunction);
    

    You could of course make this fancier and provide for other execution modes, or whatever. You didn’t describe the overall point of this code so I don’t really know what more you’d want.

    edit — one more note: many people might (rightly) suggest that instead of a timer driven by the browser’s setInterval() mechanism, it might be better to use setTimeout() and do the work of setting up each subsequent timer yourself. That can be important in cases much like yours, where the amount of work done is sort-of unbounded because you don’t control what those “worker” functions do. The basic setup would be the same however.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using JavaScript, jQuery and PHP. How do I limit the JavaScript function
Possible Duplicate: Javascript function to convert color names to hex codes Is it possible
Is it possible to merge elements using XSLT. If I have the following XML
Is the following possible in SQL Server 2000? CREATE FUNCTION getItemType (@code varchar(18)) RETURNS
Possible Duplicate: Singleton: How should it be used Following on from Ewan Makepeace 's
I'm building a concert calendar that's very heavy on javascript (using jQuery). I'm having
I have the following script element in my web page: <script src=default.js type=text/javascript></script> Using
How can I achieve the following structure without using tables or JavaScript? The white
Possible Duplicates: Is the following JavaScript construct called a Closure? What do parentheses surrounding
I'm using the Java matcher to try and match the following: @tag TYPE_WITH_POSSIBLE_SUBTYPE -PARNAME1=PARVALUE1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.