In JavaScript one can get the list of arguments passed to a function via arguments
, that is an array-like object:
>> function fun(a, b, c) { console.log(arguments) };
undefined
>> fun(1, 2, 3);
[1, 2, 3]
Is there a way to obtain an object containing the formal name of each argument as well?
That is, if one calls the function like above, he should get:
{a = 1, b = 2, c = 3}