Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day383:请写出下列代码输出结果(obj 实例化,修改属性和重新实例化的指针问题) #386

Open
qappleh opened this issue Aug 23, 2021 · 1 comment

Comments

@qappleh
Copy link
Owner

qappleh commented Aug 23, 2021

function changeObjProperty(o) {
  o.siteUrl = "http://a.com";
  o = new Object();
  o.siteUrl = "http://b.com";
}

let s = new Object();
changeObjProperty(s);
console.log(s.siteUrl);
@cc7gs
Copy link

cc7gs commented Aug 23, 2021

我来抢答😉:
考察函数参数是按值传递的,对象传递的是地址,并非引用。

console.log(s.siteUrl) //. "http://a.com"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants