I want a static varible like C language

J

Jack

Hello,
Under is C procedure:
#include<stdio.h>
#include<conio.h>
void ab(int x)
{
if(x<5)
{
ab(x+1);
printf("%d ",x);
}
}
void main(void)
{
ab(1);
getch();
}

Under is ASP procedure:
<SCRIPT Language=JavaScript runat=server>
var a;
abc(0);
function abc(b)
{
abc.prototype.x=b+1;
if(abc.prototype.x<5)
{
abc(abc.prototype.x);
Response.Write(abc.prototype.x);
Response.Write(" ");
}
else
return;
}
</SCRIPT>
Run the C procedure shows "4 3 2 1 ",but load the ASP's procedure shows "5 5
5 5 ".
I want a JavaScript function like C function.That is to say,I want a varible
which in the function is static.
Thank you
 
B

Bob Barrows

Jack said:
Hello,
Under is C procedure:
#include<stdio.h>
#include<conio.h>
void ab(int x)
{
if(x<5)
{
ab(x+1);
printf("%d ",x);
}
}
void main(void)
{
ab(1);
getch();
}

Under is ASP procedure:
<SCRIPT Language=JavaScript runat=server>
var a;
abc(0);
function abc(b)
{
abc.prototype.x=b+1;
if(abc.prototype.x<5)
{
abc(abc.prototype.x);
Response.Write(abc.prototype.x);
Response.Write(" ");
}
else
return;
}
</SCRIPT>
Run the C procedure shows "4 3 2 1 ",but load the ASP's procedure
shows "5 5 5 5 ".
I want a JavaScript function like C function.That is to say,I want a
varible which in the function is static.
Thank you

How's it feel to want? :)

Try .scripting.jscript
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,371
Latest member
Brkaa

Latest Threads

Top