'Ambigous data type in javascript [duplicate]

[enter image description here][1]

I print a variable by console.log(TotalTime) and this is the result. It looks like an array but it's not. There are some other console.log commands: console.log(typeof TotalTime) => Object console.log(TotalTime[0]) => undefine i need to access the element shown in the picture but i couldn't. How can I get it? I need to calculate the sum of it. Here is my code:

getLightTimeUsing = async () => {
    const url = "";
    const devices = await axiosClient.get(url);
    var totalTime = [];

    devices.forEach(async (device) => {
      // console.log(device);
      if (device.description === "light") {
        let lightdevices = await this.getFeedData(device.key);
        lightdevices = [...lightdevices.reverse()];
        // console.log(lightdevices.length);
        lightdevices.forEach((ldevice, index, arr) => {
          if (index % 2 !== 1) {
            totalTime.push(
              Date.parse(arr[index + 1].created_at) -
                Date.parse(ldevice.created_at)
            );
          }
        });
      }
    });
    console.log(totalTime[0]) //=> undefine
    console.log(typeof totalTime) //=> object
    return totalTime;
  };


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source