I've created a Javascript class called myClass with two methods in it: method1 and method2. method1 sets a value to a property called X, method2 sets another value to the same property and alerts it.
The problem is I run the code and nothing alerts. Any ideas why is this happening?
My code is below:
var myClass = function(classParamObject){
this.method1 = function() {
classParamObject.X = 'TEST';
};
this.method2 = function() {
// Even if I change the value of X to 'NEW VALUE', it is not changing
classParamObject.X = 'NEW VALUE';
// This alerts as 'TEST'
alert(classParamObject.X);
};
this.method1();
this.method2();
}