/    Sign up×
Community /Pin to ProfileBookmark

settimeout and wait

Hi,

If i understood well settimeout, it will run a “code” (function, part of code,..) at a particular time.

Settimout(“my_funct”, 2000);
will execute “my_funct” function in 2 s.

but if i write :
Settimout(“my_funct_1”, 2000);
Settimout(“my_funct_2”, 3000);

my_funct_1 will be executed in 2 s and my_func_2 will be executed only 1 s later of my_funct_1 executon has started.

so how can i do to make something like that ?
my_funct_1 : start in 2 s
my_funct_2 : start 2 s after the END of my_funct_1
it would be a typical wait or pause(2s)

thanks a lot

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@mjdamatoNov 18.2006 — Add the call to my_funt_2 at the end of my_funct_1 with a 2 second settimeout. However, unless my_funct_1 is a long complex script, it most likely completes in less than 1/100th of a second making the added complexity moot. Just call my_funct_2 right after my_funct_1 with a 4 second timeout. Because if you are wanting these to be strictly aligned with respect to time, you might want to incorporate a timestamp.
×

Success!

Help @alain spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...