JSFiddle - React, Tailwind, and code Playground

by rpflorence

JavaScript

var Attempt = new Class({
    
    attempt: function(method){
        var args = [].slice.call(arguments, 1);

        try {
            this[method].apply(this, args);
        } catch (err){
            this._call.apply(this, args);
        }
    },
    
    _call: function(){},

});

var MyClass = new Class({

    Implements: Attempt,

    _call: function(){
        console.log(arguments);
    }
    
})

new MyClass().attempt('getUsers', 'dog', [1,2,3]);