JSFiddle - React, Tailwind, and code Playground
JavaScript
var myClass = {
globalVar : {
total : 100
},
myFunction : {
getTotal : function() {
console.log(this);
return this.globalVar.total;
}
},
};
// Uncaught TypeError: Cannot read property 'total' of undefined
alert(myClass.myFunction.getTotal() );