How to get function parameter names/values dynamically?

The following function will return an array of the parameter names of any function passed in. var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; var ARGUMENT_NAMES = /([^\s,]+)/g; function getParamNames(func) { var fnStr = func.toString().replace(STRIP_COMMENTS, ”); var result = fnStr.slice(fnStr.indexOf(‘(‘)+1, fnStr.indexOf(‘)’)).match(ARGUMENT_NAMES); if(result === null) result = []; return result; } Example usage: getParamNames(getParamNames) // returns [‘func’] getParamNames(function (a,b,c,d){}) // … Read more

Why does a function with no parameters (compared to the actual function definition) compile?

All the other answers are correct, but just for completion A function is declared in the following manner: return-type function-name(parameter-list,…) { body… } return-type is the variable type that the function returns. This can not be an array type or a function type. If not given, then int is assumed. function-name is the name of … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)