The following code snippet explains how we can use static variables
in JavaScript.
function foo() { if( typeof foo.counter == 'undefined' ) { foo.counter = 0; } foo.counter++; document.write(foo.counter+"<br />"); }
No comments:
Post a Comment