function setName(obj){
obj.name = "xiaobai";
obj = new Object();
obj.name = "xiaohei";
}
var obj = new Object();
setName(obj);
console.log("obj",obj.name);
输出xiaobai
说明:在函数内创建的对象无法作用于函数闭包之外
function setName(obj){
obj.name = "xiaobai";
obj = new Object();
obj.name = "xiaohei";
}
var obj = new Object();
setName(obj);
console.log("obj",obj.name);
输出xiaobai
说明:在函数内创建的对象无法作用于函数闭包之外