无法在循环之外访问数组元素

问题:

  • 当我尝试在循环内控制台记录阵列时,它显示出结果已添加到阵列中。但是,当循环外时,我在console.log上得到一个空数组
var ResultArray01=  [];
for(var gg=0; gg<ResultArray.length;gg++)   // ResultArray is come from another function
{
  IPFS.get.call(ResultArray[gg],function(error, result) {      //this function is about smart contract
  if (error) 
  {
    console.log(error);
  }
  else
  {
    ResultArray01[gg] = result;    //get the result, and store it into ResultArray01
    console.log(ResultArray01[gg]);    //it can successfully print the value
  }
  });

}
console.log(ResultArray01);    //returns empty array

有人能帮我吗?谢谢