I want implement function queue,where it should be executed based upon passed in time delay. If any of the function in the queue is invoked before the delay, then queue must not execute that function and should be moved to the next function in the queue.
For example:
function funQueue(message,date){
//logic
}
var fn1=funQueue("message1",new Date().getTime()+500)
var fn2=funQueue("message2",new Date().getTime()+1000)
var fn3=funQueue("message3",new Date().getTime()+2000)
fn2()
When it is executed like the above it should print.
message1
message3
please note message2 is not printed.
Thanks all,
var fn2is not executed? You can't tell if this function will ever be called againfn2()- that executes itfn1andfn3is not called again. You do not assign function, you assign value of function return. So what is the logic?funQueue()to take a function as an argument, and execute that function after the specified delay? (You just want it to display a string message?)