On Sat, Sep 5, 2009 at 6:48 AM, Malte<[email protected]> wrote:
> On Aug 2, 4:34 am, Luke Maurer <[email protected]> wrote:
>> On Jul 29, 7:50 pm, Nicolas Hatier <[email protected]> wrote:
[posting order restored]
>>
>> > You can use this syntax:
>>
>> >functioncompose (fn1, fn2) {
>> > // returns afunctionthat calls fn1 with the result of fn2
>> > functioninner() {
>> > return fn1( fn2.apply(null, arguments))
>> > }
>>
>> > return inner;
>>
>> > }
>>
>> > This is perfectly valid javascript and will do exactly what you want,
>> > while providing anamefor the innerfunction.
>>
Yes.
Named FunctionExpression does not work consistently in JScript and
errs in Safari 2. FunctionStatement is supported in Spidermonkey and I
don't know where else, but probably not that widely supported. Last
week I posted an example of GMail doing that.
>> But you have to call thefunctionthe same thing every time. What Red
>> wants to do is call it something different depending on the arguments.
>>
>> The best solution I know of is to use an eval to wrap thefunction:
>>
>> functionrename(f,name) {
>> return eval('(function' +name+ '() { return f.apply(this,
>> arguments); })');
>>
>> }
>>
(did gmail remove whitespace there?).
Don't use eval for that. Or the Function constructor. You don't really
need it and if the reason for adding it is to make debugging easier,
you might want to question if a function created by eval has the
opposite effect.
> Hi,
>
> WebKit added support for this a while ago with func.displayName that
> usually has the same value as func.name
A function's |name| is a nonstandard extension.
javascript: function xxx(){} alert( [xxx.name, xxx.displayName+""] )
Webkit, Chrome, Seamonkey:-
elert: "xxx, undefined"
A function may have a nonstandard |name| property set automatically in
some browsers. The |displayName| property is not set automatically in
any of the three tested browsers.
By using FunctionDeclaration, where syntactially valid, an identifier
is assigned.
Regards,
Garrett
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Firebug" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/firebug?hl=en
-~----------~----~----~----~------~----~------~--~---