I used to think that i have decent understanding of Javascript core. But I came across this little tweak in my code and I realised i do not know much about core. Code is like that -
// FIle: test.js
let testOuter = (a,b) => {
return a+b;
}
module.exports = {
testInner: (a,b) => {
return a+b;
},
test: (a,b) => {
return module.exports.testInner(a,b); // Case 1: Works Fine
return testOuter(a,b); // Case 2: Works Fine
return this.testInner(a,b); // Case 3: Does'nt work
})
}
// File: CheckTest.js
let x = require('./test.js')
let a = x.test(2,5);
console.log(a);
After lot of search I found many things to learn and to know about scope and scope chain. But still I don't get satisfaction why case 3 is not working. I just need a deep understanding of this CASE 3 also I will really appreciate if you can provide good content to understand core JS.