JSFiddle - React, Tailwind, and code Playground

JavaScript

var A = function(arg){
    this.storedArg = arg;
    this.callback = function(){ alert(this.storedArg); }
}
        
var B = function() {
    this.doCallback = function(callback, context) {
        callback.apply(context); 
    };
};  

var pubCallback = function(){ alert('Public callback') };

var a = new A(123);
var b = new B();

b.doCallback(pubCallback); // works as expected
b.doCallback(a.callback, a);  // want 123, get undefined