I have the following javascript function whose parameter names I need to get dynamically
static checkNotNull() {
for (let arg of arguments) {
if (arg === undefined || arg === null || arg === "") {
return `${this._params(function(arg){})} is missing`;
}
}
}
static _params(func) {
var args = func.toString().match(/function\s.*?\(([^)]*)\)/)[1];
return args.split(',').map(function (arg) {
return arg.replace(/\/\*.*\*\//, '').trim();
}).filter(function (arg) {
return arg;
});
}
I wish to know the name of the arg
that was passed while iterating through the arguments object.
I saw this question in stackoverflow How to get function parameter names/values dynamically? but it still couldn't solve my problem for my current use case.
Is there a work around for my current use case?