var dataset = { num: 20 };
var svg = { w: 600 };
var column = {
padding: 0.2,
w: (svg.w/dataset.num)/(this.padding + 1),
print: function(){
console.log("through obj methord:" +
(svg.w/dataset.num)/(this.padding + 1)
);}
};
column.print();
console.log(column);
above is the code, and it could be executed, and in the result, you could see the result of column.w is NAN, while the same calculation in the obj's method: print could give back the right answer: 25.
how could it be? even though i replaced (svg.w/dataset.num)/(this.padding + 1) by svg.w/(dataset.num*(this.padding + 1)) ,it is exactly the same. after i replace the variables like svg.w, dataset.num with its values, column.w becomes value 25 of course.