Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #11715
| From | Andreas Bergmaier <andber93@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Simple parameter passing within a setInternal() call? |
| Date | 2012-02-12 03:04 +0100 |
| Organization | albasani.net |
| Message-ID | <jh76n4$7ih$1@news.albasani.net> (permalink) |
| References | <jh6e3o$73s$1@news.albasani.net> <jh6jln$jjo$1@news.albasani.net> <1350222.i9fspTd0WE@PointedEars.de> <jh6mr2$rbb$1@news.albasani.net> <8011104.oiZZxVaoWa@PointedEars.de> |
Thomas 'PointedEars' Lahn schrieb:
> Andreas Bergmaier wrote:
>> Thomas 'PointedEars' Lahn schrieb:
>>> Andreas Bergmaier wrote:
>>>> Another alternative is to use bind() or other functions, to return a
>>>> function which calls repeatingStuff with the needed parameters
>>>
>>> This works in implementations of ECMAScript 5.x or where you have a
>>> suitable scripting framework that emulates Function.prototype.bind(), but
>>> it is unnecessarily inefficient by comparison.
>>
>> Is it? Unnecessarily in this case, yes, but if you have defined
>> "repeatingStuff" elsewhere it is imho much more elegant than coding
>>
>> var x;
>> setInterval( function(){
>> doRepeatingStuffWith(x);
>> }, 5000);
>
> That is not even equivalent in the first place. Clearly you do not
> understand bind(). Please refrain from recommending it until you do.
I do, and I never said it was to be equivalent. Of course bind() needs a
context to set, dereferences x, and builds a new function. That even
could be useful (I'm not sure what the OP needs), so why shouldn't I
mention it as an alternative?
Bergi
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