Output abnormal .. WHY? : <p>I have many days that I can not run this script!</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var b = [9,8,7,6,5,4,3,2,1]; 
var a = (function(){ 
  var W = []; 
  for(var k in b){ 
    W[W.length] = { 
      index : k, 
      fx : function(){ 
        console.log(k); 
      } 
    } 
  } 
  return W; 
})(); 
 
console.log(a); 
for(var j = 0; a[j]; j++)a[j].fx();</code></pre>
</div>
</div>
</p>

<p>Because it does not produce as OUTPUT numerical sequence <strong>987654321</strong>?</p>
