class Base { prefix = "base"; read(value) { return this.prefix + ":" + value; } } class Middle extends Base {} class Leaf extends Middle { own(value) { return this.read(value); } } const helpers = { invoke(value, input) { return value.read(input); }, own(value, input) { return value.own(input); }, extract(value) { return value.read; } }; export function run() { const first = new Leaf(); const second = new Leaf(); second.prefix = "second"; console.log(helpers.invoke(first, "inherited")); console.log(helpers.own(first, "own")); const method = helpers.extract(first); console.log(method === helpers.extract(second)); console.log(method.call(second, "detached")); }