Last active
August 17, 2017 09:52
-
-
Save A1rPun/ed2bca9ce53d925315b2 to your computer and use it in GitHub Desktop.
Javascript get parameter names from function reference
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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