I wonder if it is a bug in the language itself.

  node.js, question

First look at the code:

var foo, bar;
 
 foo = new Array(8);
 
 bar = foo.map(function () {
 return 1;
 });
 
 //Note 1
 console.dir(bar);  // => [undefined × 8]
 
 foo[6] = 1;
 
 console.dir(foo);  // => [undefined × 6, 1, undefined × 1]
 
 bar = foo.map(function () {
 return 2;
 });
 
 console.dir(bar);  // => [undefined × 6, 2, undefined × 1]

I don’t know if you great gods see the problem, maybe I can’t “kung fu” home, maybe there is no problem.

I describe the following problem:Why is the result of printing not [1,1,1,1,1,1,1,1,1,1,1] when making a comment?.

foo = new Array(8);
 foo.forEach(function(v, i) {
 console.log(v, i);
 });
 //No output
 
 foo[3] = 1;
 foo.forEach(function(v, i) {
 console.log(v, i);
 });
 //Only one row of output: 1 3
 
 foo = [];
 foo.length = 8;
 foo.map(function() {
 return 1;
 });
 // [undefined x 8]

It is probably related to the implementation of Array. There will be different effects on IE (I used 11).