You'll have to use a named function expression (with all its idiosyncrasies):
var methods = {
init : function init () {
var arity = init.length;
}
};
Here's the fiddle: http://jsfiddle.net/tqJSK/
To be honest though, I have no idea why you'd ever need this. You can hard code that number within the function, since the amount of named arguments will never change...
Update: as pointed out by @T.J.Crowder, you can use regular function declarations instead:
(function($, window, document) {
function init () {
var arity = init.length;
}
var methods = {
init : init
};
}(jQuery, window, document));
Update 2: if all you're looking for is the number of arguments supplied in this specific call, just use arguments.length
:
var methods = {
init : function () {
var count = arguments.length;
}
};
Here's the fiddle: http://jsfiddle.net/tqJSK/1/