JSFiddle - React, Tailwind, and code Playground
JavaScript
function myObject() {
var that = this;
this.variable1 = "tst";
this.function1 = function() {
//Now this function works. A 'this' function to a private function is ok
_PrivateFunction1();
//Here is error one, I cannot seem to call methods within the object
//from.
this.function2();
}
this.function2 = function() {
alert("look! function2!");
}
function _PrivateFunction1() {
//This does work though. I am confused.
_PrivateFunction2();
}
var _PrivateFunction2 = function() {
alert("look! PrivateFunction1");
//this does not work.
alert(that.variable1);
alert('this === window ' + (this === window));
}
}
obj = new myObject();
obj.function1();