[英]Reference Data Type compares with Primitive Data Type in JavaScript
I am a little bit confused about this topic for example 例如,我对此主题有些困惑
var person = "Kobe";
var another = person;
is variable another create an another copy or just reference to person? 是变量另一个创建另一个副本或只是引用人? That being said, if I change person to something else, will another also be changed?? 话虽这么说,如果我把人换成别的东西,另一个人也会变吗?
Compare to 相比于
var person = {name: "Kobe"};
var another = person;
Thanks for the help 谢谢您的帮助
字符串(以及数字和布尔值)在JS,对象和函数共享引用中赋值时被复制
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.