that is my code
var idList = [];
$('.savearray').each(function(index, element) {
  //idList.push($(element).val());
  var selectedbox = $(element).val();
  var store_num = document.getElementById("store").value;
  $.post( "classes/qetitemqty.php", { ID: selectedbox, store_num: store_num})
    .done(function( data ) {
      idList.push(data);
      //idList.push(JSON.parse(data));                          
    });
});
console.log(idList);
my array coming empty like this put have length with correct response
[]
  0: "1"
  1: "1" 
  length: 2__proto__: Array(0)
 
     
    