-3

我在这样的函数中有一个 for 语句:

for(i=0;i<=nc;i++){
var nd = //how many times this for statement has run+1
//if the for statement runs for the first time nd would be 1, second time nd would be 2, the for statement will run a total of "nc" times
this.id=nd }

我将如何做到这一点?

4

3 回答 3

1

你是这样的意思吗?

for(i=0;i<=nc;i++){
   var nd = i+1;
   this.id=nd;
}
于 2012-10-13T22:05:31.313 回答
1

我不知道你想要达到什么目的

for(i=0;i<=nc;i++)
{
   this.id = i+1; 
}
于 2012-10-13T22:09:38.247 回答
0

在函数之外声明 nd

var nd = 0;
function...
    nd++;
    this.id = nd;
于 2012-10-13T22:06:42.887 回答