简体   繁体   中英

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,对象和函数共享引用中赋值时被复制

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM