这纯粹是好奇。让我们写一个对象:
var display = { res1:{ w:640, h:480 }, res2:{ w:320, h:240 }, nores:{} };
现在从这个对象,我们将nores属性发送到一个函数。因为nores是一个对象,所以我们改变的任何东西somefunction都会在后面看到display.nores:
somefunction(display.nores);
现在问题来了。鉴于 display 是在闭包内定义并在该闭包之外定义的,是否somefunction()有任何形式的访问display的其他属性(res1/ ) ?我的意思是它可以仅从作为参数传递的属性中引用整个对象吗?res2somefunction()displaynores