Here is a piece of code which makes number increment by one when clicking the button:

```
<script type="text/javascript">
    var incrementClickCount = (function () {
        var clickCount = 0;
        return function () {
            return ++clickCount;
        }
    })();
</script>
<input type="button" value="click me" onclick="alert(incrementClickCount());" />

```

What I don't know is that, I think we should get value "1" everytime when we click the button, so the sequences will be

**Step 1:** self invoked outer function call by self, the definition of inner anonymous function is stored in increment `incrementClickCount` variable.

**Step 2:** When click the button, call the inner anonymous function to change value of `clickCount` from 0 to 1, so we get 1 as input, fair enough.

**Step 3:** Here is the tricky part I don't understand here, when we click the button again. we actually call a new inner anonymous function, so the input should be 1 again, why it is 2 now? Just like this normal java or C# function:

```
public int getNumber()
{
   int clickCount = 0;
   return addNumber(clickCount);
}

public int addNumber(int number)

{
   return number++;
}

```

no matter how many times I call `getNumber()` function, I always get 1 rather than 1,2,3,4,5 ....