如何从函数中设置数组的值?问题是因为我必须在使用变量值设置之前更改索引的值。
function foo(arr) {
this.arr=arr;
}
var f = new foo(['a', 'b', 'c']);
// I had thinked in use a function like this one
// Note thta I used index to pass an array wich could
// be greater than 1 dimension.
foo.prototype.setv = function(index, v) {
this.arr.index = v;
}
// but it does not works like I was expecting
idx = [1];
foo.setv(idx, "Z");