Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap

Q946 Why is the first parameter of the setTimeout() method enclosed in quotes?

You are here: irt.org | FAQ | JavaScript | Timeout | Q946 [ previous next ]

Its an expression to be evaluated at the time of the execution.

If you did:


Then the test() function will be evaulated straight away and the result returned as the expression to be evaluated after a five second delay, which is probably not want you want.

But this could be useful, for example:

<script language="JavaScript"><!--
function test1() {
    alert('test1() function invoked immeadiately');
    return 'test2()';

function test2() {
    alert('test2() function invoked five seconds later');


©2018 Martin Webb