JSFiddle - React, Tailwind, and code Playground
JavaScript
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
function getParamMap(func, funcArgs) {
var fnStr = func.toString().replace(STRIP_COMMENTS, '')
var names = fnStr.slice(fnStr.indexOf('(')+1, fnStr.indexOf(')')).match(/([^\s,]+)/g)
if(names === null)
names = []
args = Array.prototype.slice.call(funcArgs);
return _.object(_.zip(names, args));
}
function example(a, b, c, d) {
return getParamMap(example, arguments);
}
//IE's Object.toString is not verbose, so use JSON
console.log(JSON.stringify(example(1,2,3, "hello")));
// -> Object {a: 1, b: 2, c: 3, d: "hello"}