有什么办法,在JavaScript中,写这样一个功能:JavaScript函数编辑原始对象
var a = "Hello"
function change(variable, value) {
//Code that edits original variable, not the variable argument
}
alert(a)
change(a, "World!");
alert(a);
,这将首先输出“你好”,然后在“世界!”。有什么办法可以写出这样的功能吗?
不,但您可以将该值封装在对象中,并将其修改为对象的属性。 – 2014-10-22 04:53:16