有没有办法将变量的引用作为函数/对象参数?
示例:
function Character(name,age,...){
this.name = name;
this.age = age;
...
}
function Something(age){
this.age = age;
}
当我运行以下代码时:
var a = new Character('John', 23);
var b = new Something(a.age);//with reference
var c = new Something(33);//without reference
a.age++;
//a.age is now = 24 but b.age is still 23
有没有办法对变量进行引用并将其作为参数?
对不起我的英语不好。