Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - JS function call and scope chain
JS function call and scope chain
The array index should be plastic, that is, the key in xx[key] must be plastic. The' V'+I you passed is wrong, so it should be written as follows:

(Function () {

A = function () {

var xx = new Array();

for(var I = 1; I < = 3; i++) {

xx2(xx,I,' x '+I);

}

alert(" xx . length = "+xx . length "); // ? Why is xx.length equal to 0 here?

Return xx;

};

xx2 = function(xx,key,value) {

Xx[key] = value;

};

var b = a();

Alert (b); //Why is the displayed b empty?

})();