为什么我不能遍历此对象的项目?

我是TypeScript和JavaScript的新手,我遇到了问题。我具有从其他应用程序复制粘贴的功能,但是我对其做了一些修改:

myServer.prototype.filterList = function(_data, filterModel) {
  const resultOfFilter = [];
  function filterData(filtModel) {
    let httpParams = new HttpParams();
    for (const f in filtModel) {
      // some code
    }
    const httpOptions = {
      params: httpParams,
    };
    return that.httpClient.get(`${baseUrl}${tableName}`, httpOptions);
  }

  filterData(filterModel).subscribe((filteredData: any[] ) => {
    filteredData.forEach((item) => {
      resultOfFilter.push(item);
    });
  });

  return resultOfFilter;
};

This function returns an array like that: enter image description here

我将此数组传递给另一个要在其项目上迭代的函数。我尝试了以下方法:

一个)

resultOfFilter.forEach(i => {
    console.log('I:', i);
  });

b)

for (let i; i <= resultOfFilter.length; i++){console.log('I:', resultOfFilter[i]);}

C)

Object.keys(resultOfFilter).forEach(i => {
    console.log('I:', i);
  });

But all these functions did not work for me. And I can't understand why. I can display the whole array, but I can't get its items for some reason. Please advise how can I get each item of that array. P.S.: When I use typeof resultOfFilter I get object.

评论