<script> var name="window object"; var object={ name:"my object", getName:function(){ console.log(this.name); } } object.getName(); (object.getName=object.getName)(); </script>
my object (this指向当前调用的对象)
window object (object.getName赋值给object.getName,然后自调,指向全局)
为什么我把前面那个object.getName()这个函数的调用去掉,(object.getName=object.getName)();就会报错,提示Uncaught TypeError: Cannot read property 'getName' of undefined
@吕瑞芳: 因为;的问题,你在var object={}后加;
具体原因,可参考文章http://www.cnblogs.com/daysme/p/6440012.html