snipt

Ctrl+h for KB shortcuts
#23062

JavaScript

Passing parameters in a function called inside setTimeout

/* Passing parameters in a function called inside setTimeout */
setTimeout(function(){myFunction(parameter)},timeOutInMillisecondsHere);
https://snipt.net/embed/9b72716210bc8d386dc2445aec00f839/
https://snipt.net/raw/9b72716210bc8d386dc2445aec00f839/
9b72716210bc8d386dc2445aec00f839
js
JavaScript
2
2014-04-17T16:54:28
True
False
/api/public/snipt/23062/
passing-parameters-in-a-function-called-inside-settimeout
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cm">/* Passing parameters in a function called inside setTimeout */</span> </span><span id="L-2"><a name="L-2"></a><span class="nx">setTimeout</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span><span class="nx">myFunction</span><span class="p">(</span><span class="nx">parameter</span><span class="p">)},</span><span class="nx">timeOutInMillisecondsHere</span><span class="p">);</span> </span></pre></div> </td></tr></table>
javascript, settimeout