I’ve been around javascript for a long time, but am pretty rusty with javascript Classes. For a particular project I’m working on, things are starting to get unwieldy and I’d like to start cutting up my code into separate files. I don’t want to have to import
all my functions explicitly, so I’ve started wrapping them up into a Class
(which makes sense for other reasons also). Some of my functions return callbacks (functions). That is:
return functionName;
Which I can use like:
var callBack = functionReturningFunction();
...
callBack();
I cannot find any information about returning and passing methods, rather than functions what is the syntax there? Ideally I’d like to pass in methods as arguments to the constructor so I can say:
const myObject = new MyClass(methodName);
So I don’t have to do:
const myObject = new MyClass();
myObject.methodName();