JavaScript anonymous functions - how to determine available parameters?

I am using the following code snippet from the documentation of a tool (FullScale Dangle):

$scope.displayCoord = function(type, term) {
    console.log(term);
    console.log(type);
};

This function is called on-click after being routed through the tool's own library. According to the documentation, I have the parameters type, and term available to the function after the onclick.

How can I determine what additional parameters are available?

Answers


Use the arguments array-like object. This means you can do arguments.length to see how many there are, and access them as arguments[0] (type), arguments[1] (term), and any others that may be there.


Using the arguments object, something like this should do it:

var f = function (args1, args2) {console.log(arguments);}("foo", "bar", "bing");

["foo", "bar", "bing"]


As mentioned in the other answers, you can use the arguments object. Here's more information available on it's use. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/arguments


Need Your Help

how to combine two tables and count their values as one?

mysql sql

I want to get the total numbers of committed crimes when combining the two tables.

Jackson circular reference (2.0)

java json spring jackson circular-reference

I have a user -> hasMany userPermission, and am getting a circular reference when spring MVC tries to output JSON. If I set the user permissions to null, it works. If I have a user->hasmany->