Skip to content

Instantly share code, notes, and snippets.

@charlesponti
Created December 25, 2014 10:34
Show Gist options
  • Save charlesponti/69798093b31606ad1c2c to your computer and use it in GitHub Desktop.
Save charlesponti/69798093b31606ad1c2c to your computer and use it in GitHub Desktop.
Get JavaScript function argument names
var x = function(x, y) {
/** code */
};
x.toString()
.replace(/((\/\/.*$)|(\/\*[\s\S]*?\*\/)|(\s))/mg,'')
.match(/^function\s*[^\(]*\(\s*([^\)]*)\)/m)[1]
.split(/,/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment