var stack = new Array();
var ii = 0;
function pushTutor(item) {
var jj = stack.length;
for(ii=0;ii<jj;ii++) {
stack.push(item开发者_开发百科);
alert(stack);
}
}
I remember the stack.length cause the issue which is not able to loop at all. What is the solution for this?
Well, aside from the fact that you don't need a for loop for what you're trying to achieve here, stack has no items, so its length is 0. As such, your loop will never execute.
If you just want to push the item, surely it'd be better to do:
function pushTutor(item)
{
stack.push(item);
alert(stack.length);
// Alerting stack here would simply alert 'array'
}
The code does not make sense.
Perhaps you want
var stack = new Array();
function pushTutor(item) {
stack.push(item);
alert(stack);
}
stack is empty, that's a problem.
加载中,请稍侯......
精彩评论