the html and javascript is below:
<script>
    function a(k)
    {
        var i=0;
        if(k==0)
        {
            function b()
            {
                alert(++i);
            }
            return b;
        }
        else
        {
            function c()
            {
                alert(++i);
            }
            return c;
        }
    }
    var d=a(0);
    var e=a(1);
</script>
    <button onclick="d()">clickme</button>
    <button onclick="e()">clickme2</button>
the html and javascript is above.
I click the button "clickeme" first, the browser alert"1"; then I click the button "clickme2",the browser alert "1" too.
why?
after I click the button "clickme",the variable "i" have changed to 1;then,when I click the button "clickme2" the browser should alert "2". why?
the local function of b() and c() has it's own copy of variable "i"?
 
     
    