var locations = [];
$.getJSON("locations.json", function(json) {
  console.log(json);
  json.forEach(function(locItem){
    locations.push(locItem);
  });
});
console.log(locations);
The line 3 log did print my json list but the line 9 log only gives []. I tried using window.locations, global.locations or define something like
var self = this;
in global scope and then use self.locations inside the funciont. None of them works.
 
     
     
     
    