在javascript中,如果我不使用类,我可以这样做:
const Module = (function(){
const myArray = [];
const myObject = {};
return { //this is my interfaces
myArray,
myObject,
myMethod1,
myMethod2,
myMethod3,
myMethod4,
myMethod99,
}
function myMethod1(){}
function myMethod2(){}
function myMethod3(){}
function myMethod4(){}
function myMethod99(){}
})
现在,javascript中类的情况不同了:
class Module{
constructor(){}
myMethod1(){}
myMethod2(){}
myMethod3(){}
myMethod4(){}
myMethod99(){}
}
在这种情况下,我无法将接口和实现分离开来,因此很难在代码中导航。Javascript有没有可能处理这种情况?