JSFiddle - React, Tailwind, and code Playground

JavaScript

function fmap3(firstArgFunc, secondArgFunc) {
    
    return function(){
        
        
        var result;
        var varTmp = secondArgFunc.apply(this, arguments);
        
        if (!Array.isArray) {
            Array.isArray = function(arg) {
                return Object.prototype.toString.call(arg) === '[object Array]';
            };
        }
        
        if (varTmp.isArray) {
            result = firstArgFunc.apply(this, arTmp);
        } else {
            result = firstArgFunc(varTmp);
        }
        
        
        return result;
    }
    
}