I have 2 js files:
file1.js contains prototype A with:
printname: function() {
console.log('my name is A');
}
getname: function() {
console.log('getting name..');
this.printname();
}
Then I put 'getname' function in a global variable because I want to access it anywhere:
globalvar.myfunction = this.getname;
file2.js contains prototype B with:
runmyglobalfunction: function() {
globalvar.myfunction();
}
When I call this.runmyglobalfunction, the result is:
I can see console log 'getting name..'.
But I can't see 'my name is A'
How do I fix this?