I've exported a function and imported it in Javascript, but the only way i can access the functions inside it is by typing it like this:
myModule.mainFunc().func1()
But what i'm trying to achieve is more like this:
myModule.mainFunc.func1()
Currently it gives an error if i try to reference to it like this.
I've tried returning the values of the functions as objects but it still needs me to call it as functions.
function greet() {
var hello = () => {
console.log("hello there");
};
var hi = () => {
console.log("hi there");
};
return { hello: hello, hi: hi }; // I've tried this doing it like this
}
export default {greet};
Here's how I'm importing it:
import greetings from "./index.js";
greetings.greet().hello()