Skip to content

Instantly share code, notes, and snippets.

@A1rPun
Last active August 17, 2017 09:52
Show Gist options
  • Save A1rPun/ed2bca9ce53d925315b2 to your computer and use it in GitHub Desktop.
Save A1rPun/ed2bca9ce53d925315b2 to your computer and use it in GitHub Desktop.
Javascript get parameter names from function reference
function getParameters(func) {
var funcString = func.toString();
var indexStart = funcString.indexOf('(') + 1;
var indexEnd = funcString.indexOf(')');
return funcString
.substring(indexStart, indexEnd)
.trim()
.split(/\s*,\s*/);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment