var p = {// x and y are regular read-write data properties.x: 1.0,y: 1.0,r:function () { return Math.sqrt( x*x + y*y); },
};
如果调用 p.r(),会报错的, r函数里面必须要用 this来引用 x和y。你悟到了什么呢?
JS-- 小细节--你悟到了什么?
原文:http://www.cnblogs.com/aimkk/p/7615067.html