You could use a named function expression:
app = {
init: function init() {
console.log(arguments.callee.name);
}
};
app.init(); // => "init"
Note that use of arguments.callee
is forbidden in strict mode.
What you are doing in your example is assigning an anonymous function expression to the property named init
on your object. The function itself does not have a name unless you use a named function expression.