JSFiddle - React, Tailwind, and code Playground
JavaScript
function corredor(fn, argumentos, fallback) {
var func = typeof fn === "function" ? fn : fallback;
return func.apply(this, argumentos);
}
var foo = 'string';
var retorno = corredor(foo, [1, 2, 3], function () {
return [].reduce.call(arguments, function (a, b) {
return a + b;
});
});
console.log(retorno);