By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,771 Members | 1,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,771 IT Pros & Developers. It's quick & easy.

Javascript STATIC VARIABLE?

P: n/a
is there a way to declare static variable in a function like so?

function foo(){
static count;

count++;
}

Thank you.
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.