More information about the Underscore mailing list

[_] js, object literal, giving a method/function a name

juan kennaugh contact at jkennaugh.co.uk
Tue Aug 6 16:29:49 BST 2013

yeah - I was thinking that's the only use really.

Juan


On 06/08/2013 15:59, Shiyaz Rasheed wrote:
> Hi Juan,
>
> Adding a name to the function definition has an advantage in that the
> function is no longer 'anonymous'... Could be useful during inspection and
> debugging.
>
> Cheers,
>
> Shiyaz
>
>
> On Tue, Aug 6, 2013 at 3:53 PM, juan kennaugh<contact at jkennaugh.co.uk>wrote:
>
>> Hi all
>>
>> just wondering...
>>
>> came across this syntax for a method on an object literal (adding a name
>> to the function definition)
>>
>> var objlit = {
>>      func1: function nameoffunction () {
>>          // dostuff
>>      }
>> }
>>
>>
>>
>> objlit.func1.name outputs: nameoffunction
>>
>>
>> just wondering what use that could be/ why someone would do it
>>
>>
>> Cheers
>>
>> Juan
>>
>> --
>> underscore_ list info/archive ->  http://www.under-score.org.uk/**
>> mailman/listinfo/underscore<http://www.under-score.org.uk/mailman/listinfo/underscore>
>>