我在这样的函数中有一个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 }
我将如何实现这一目标?
答案 0 :(得分:1)
for(i=0;i<=nc;i++){
var nd = i+1;
this.id=nd;
}
答案 1 :(得分:1)
我不知道你想要用什么来实现
for(i=0;i<=nc;i++)
{
this.id = i+1;
}
答案 2 :(得分:0)
在函数
之外声明ndvar nd = 0;
function...
nd++;
this.id = nd;