文章 评论 浏览 29
// 这里把o改成a // webSite引用地址的值copy给a了 function changeObjProperty(a) { // 改变对应地址内的对象属性值 a.siteUrl = "http://www.baidu.com" // 变量a指向新的地址 以后的变动和旧地址无关 a = new Object() a.siteUrl = "http://www.google.com" a.name = 456 } var webSite = new Object(); webSite.name = '123' changeObjProperty(webSite); console.log(webSite); // {name: 123, siteUrl: 'http://www.baidu.com'}
非常nice 这个题目和var a = { n: 1 };var b = a;a.x = a = { n: 2 };console.log(a.x) // undefinedconsole.log(b.x) // {n:2}这种类似
第二行看到了错别字
文章 0 评论 0
接受
非常nice 这个题目和
var a = { n: 1 };
var b = a;
a.x = a = { n: 2 };
console.log(a.x) // undefined
console.log(b.x) // {n:2}
这种类似
第 98 题:写出如下代码的打印结果