I am trying to debug fairly simple Javascript using console.log, but it outputs values ββfor variables that don't change until after calling console.log when the variables are members of the class (Chrome 22, Firefox 16).
An example of what I expect will be as follows:
var a = 1; console.log(a); a += 20;
But if the variable is a member of the class:
var a = new myClass(1); console.log(a); ax += 20; //console output says ax is 21
If the console does not register the value, how does it exist, when the log is called, when does it finally decide to write the value, and how can I get around this ??
fwiw is the complete code:
function myClass() { myClass.myClass.apply(this, arguments); if (this.constructor === myClass) this.myClass.apply(this, arguments); }; myClass.myClass = function () {}; myClass.prototype.myClass = function (x_) { if (x_ === undefined) x_ = 0; this.x = x_; } var a = new myClass(1); console.log(a); ax += 20;
source share