I know this will get down votes :), but I have to ask in case someone has ran into something similar.
I can't post the code, because to duplicate it would take quite an effort.
But, in short, I have an object Table. This object has some functions called duplicate (Table.prototype.duplicate), rotate (Table.prototype.rotate), etc.
So you end up with something like this:
var Table = function(o){
$.extend(this, o);
console.log(this._options.rotate); //Returns 49 -- How does it seems to skip?
}
Table.prototype.duplicate = function(){
console.log(this.rotate()); //Returns 49 -- this is set from elsewhere, not in this example
var n = {}
n._options = {
rotate:this.rotate()
}
console.log(this.rotate()); //Returns 49
console.log(n._options.rotate); //Returns 49
console.log(n); //Returns {_options:{rotate:0}} -- Why and HOW??
return n;
}
Table.prototype.rotate = function(){
//returns css transform angle
}
var table = new Table();
var nt = table.duplicate();
console.log(nt); //Returns {_options:{rotate:0}} -- still 0 here, but look in constructor
var table2 = new Table(nt);
The code is more complex than that, but that is the jist of it. Basically, two console.logs in a row seem to produce different results.
After the call to the function, it still reports a 0 value. But when passed back to the constructor, it has it's value again.
Can you think of why I would be seeing something like this?
Thanks.
Solution As pointed out by Felix King, using JSON.stringify(n) grabs the current value instead of Webkit's lazy loading value