471,886 Members | 1,068 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,886 software developers and data experts.

Javascript STATIC VARIABLE?

is there a way to declare static variable in a function like so?

function foo(){
static count;

count++;
}

Thank you.
Jul 23 '05 #1
1 15313
john_doe9 wrote:
is there a way to declare static variable in a function like so?

function foo(){
static count;

count++;
}

Thank you.


function foo()
{
foo.count = ++foo.count || 1;
alert(foo.count);
}

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Geoff | last post: by
6 posts views Thread by Alex Fitzpatrick | last post: by
5 posts views Thread by seans | last post: by
2 posts views Thread by ksr | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.