Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get params from function js

var STRIP_COMMENTS = /((//.*$)|(/*[sS]*?*/))/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;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #params #function #js
ADD COMMENT
Topic
Name
1+1 =