Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #11733
| From | Dr J R Stockton <reply1206@merlyn.demon.co.uk> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Simple parameter passing within a setInterval() call? |
| Date | 2012-02-12 22:02 +0000 |
| Organization | Home |
| Message-ID | <wU5jsAUlbDOPFwgx@invalid.uk.co.demon.merlyn.invalid> (permalink) |
| References | <jh6e3o$73s$1@news.albasani.net> <jh6g5k$bfn$1@news.albasani.net> |
In comp.lang.javascript message <jh6g5k$bfn$1@news.albasani.net>, Sat,
11 Feb 2012 20:39:32, Tuxedo <tuxedo@mailinator.com> posted:
>Tuxedo wrote:
>
>[...]
>
>> setInterval('repeatingStuff(x)',5000). How can the parameter between the
>
>I thought I had tried this already but I must have simply got the quoting
>wrong. Of course, this works:
>setInterval('repeatingStuff("' + x + '")',5000);
That will use the value of x at call time, if x is simple or an
expression.
Another way is to pass x as a global variable; or, perhaps more clearly,
as a property of a global Object reserved and named, or otherwise
suitable, for the purpose. Actually, repeatingStuff is such an Object.
That eliminates conversions to/from String, which may be inexact.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Simple parameter passing within a setInternal() call? Tuxedo <tuxedo@mailinator.com> - 2012-02-11 20:04 +0100
Re: Simple parameter passing within a setInterval() call? Tuxedo <tuxedo@mailinator.com> - 2012-02-11 20:39 +0100
Re: Simple parameter passing within a setInterval() call? Dr J R Stockton <reply1206@merlyn.demon.co.uk> - 2012-02-12 22:02 +0000
Re: Simple parameter passing within a setInternal() call? Andreas Bergmaier <andber93@web.de> - 2012-02-11 21:39 +0100
Re: Simple parameter passing within a setInternal() call? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-11 22:06 +0100
Re: Simple parameter passing within a setInternal() call? Andreas Bergmaier <andber93@web.de> - 2012-02-11 22:33 +0100
Re: Simple parameter passing within a setInternal() call? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-11 23:44 +0100
Re: Simple parameter passing within a setInternal() call? Andreas Bergmaier <andber93@web.de> - 2012-02-12 03:04 +0100
Re: Simple parameter passing within a setInterval() call? Tuxedo <tuxedo@mailinator.com> - 2012-02-12 09:22 +0100
csiph-web