javascript 数据类型
原始类型:数字、字符串、布尔、null、undefined 传值
对象类型:对象、数组、函数 传址 引用
--------------------------------------------------------------------------
var oldObj = {
name: "zxc",sex: "male",age: "24",address: "beijing"
};
var oneObj = oldObj;
var twoObj = oldObj;
twoObj.name="heping";
console.log(oneObj,"
");
console.log(twoObj,"
");
{"heping","male","24","beijing"}
{"heping","beijing"}
var oldObj = {
name: "zxc",address: "beijing"
};
var oneObj = oldObj;
var twoObj = {};
for(item in oldObj) {
twoObj[item] = oldObj[item];
}
twoObj.name="heping";
console.log(oneObj,"
");
{"zxc","beijing"}
angular代码
this.oldObj = {
name: "zhang.x.c",age: "25",address: "beijing"
};
this.oneObj = this.oldObj;
this.twoObj = {};
for(let item in this.oldObj) {
this.twoObj[item] = this.oldObj[item];
}
this.twoObj.name = "heping";
console.log(this.oneObj,"
");
console.log(this.twoObj,"
");