How to get javascript object method name?
<p>I'm currently building a bigger object and need to get faster and more specific with debugging/inspecting values/results/returns.</p>

<p>Now I thought about the following:</p>

<pre><code>var myObject = {
    whatever: null,
    whereever: null,
    debug: false,

    someFunction: function( arg ) {
        // General - would output *all* logs for all object functions.
        // if ( true === myObject.debug )
        //  console.log( 'FunctionNameHere', arg );

        // More specific - would output *only* the log for the currently targeted function
        if ( 'FunctionName' === myObject.debug )
            console.log( 'FunctionNameHere', arg );
    },
};
</code></pre>

<p>This would allow me to simply define the object var <code>debug</code> as one function name and only log this part.</p>

<p>The only problem is: How would I obtain the <code>FunctionName</code>/<code>someFunction</code>?</p>

<p><em>Sidenotes:</em> </p>

<ul>
<li><code>console.log( arguments.callee );</code> gives me the whole function source.</li>
<li><code>console.log( arguments.callee.name );</code> returns empty.</li>
<li><code>console.log( arguments.callee.toString() );</code> returns empty</li>
<li><code>console.log( arguments.caller );</code> returns <code>undefined</code></li>
</ul>

<p>If I take a look into the log of the whole object, I see <code>prototype.name="Empty"</code> and such. So no chance to get it directly out of the object.</p>

<p>Thanks!</p>
