If you can slightly modify the code, you could expose the inner method to the "outside":
class MyObjGraph {
constructor(id) {
this.drawGraph(id);
}
drawGraph(id){
var inId = id;
function m1(){
alert(inId);
}
return { // <-------- return an object of everything you want to be exposed
m1
}
}
}
const instance = new MyObjGraph();
instance.drawGraph("123").m1()
Explanation:
In your original code, the method drawGraph
does not return anything, therefor it only executes code, and nothing inside of it is accessible.
For anything to be accessible directly from a function, the function needs to have a return
statement, so when you invoke that function you get something in "return"... and that something, in this case below, is an Object with a single property: m1
(reference to the m1
inner function)