title: Array contains elements, but length === 0
body: <p>This code returns an array of strings:</p>
  
  <pre><code>var getCitiesList = function (url, callback) {
      var citiesList = [];
      var search = function (needSearch,whereSearch) {
          var re = new RegExp(needSearch,'ig'),
              matched =  whereSearch.match(re); //возвращает массив совпадений
          return matched !== null;
      };
      $.getJSON(url)
          .done(function (data) {
              $.each(data, function (index, value) {
                  if (search(input.val(), value.City)) {
                         citiesList.push(value.City);
                      }
              });
          });
      return citiesList;
  };
  </code></pre>
  
  <p>When I call it here, it is looks like empty array, but contains elements, <code>array.length === 0</code></p>
  
  <pre><code>  input.keyup(function () {
      var cities = getCitiesList('../kladr.json');
      console.log(cities); //[] but contains elements
      console.log(cities.length);//0
  });
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/bMFhS.png" rel="nofollow noreferrer">How it looks in browser</a></p>