Skip to content

Instantly share code, notes, and snippets.

@SethVandebrooke
Created December 18, 2017 15:26
Show Gist options
  • Save SethVandebrooke/b7066491760809d64d5424dd41813af0 to your computer and use it in GitHub Desktop.
Save SethVandebrooke/b7066491760809d64d5424dd41813af0 to your computer and use it in GitHub Desktop.
Get an array of the parameters defined for a given function
function definedParameters(func) {
return func.toString().split("\n")[0].match(/\({1}.*\){1}/)[0].replace("(","").replace(")","").split(" ").join("").split(",");
}
// definedParameters(function (a,b,c){return a*b*c;}) returns ["a","b","c"];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment