js синтаксис... Ошибка генерируется
// Структура:
class OHLCTime {
constructor() {
this.Open = null;
this.High = null;
this.Low = null;
this.Close = null;
this.Time = null;
}
}
// Фрагмент проблемного кода:
let first = [];
let firstIndex = 0;
let second = [];
let secondIndex = 0;
let count = 0;
let temp = "";
for (let i = 0; i < firstHistory.length; ++i) {
if (firstHistory[i] != ";") {
temp += firstHistory[i];
}
else {
if (count == 0) {
count++;
first[firstIndex] = new OHLCTime();
first[firstIndex].Open = temp;
temp = "";
}
else if (count == 1) {
count++;
first[firstIndex].High = temp;
temp = "";
}
else if (count == 2) {
count++;
first[firstIndex].Low = temp;
temp = "";
}
else if (count == 3) {
count++;
first[firstIndex].Close = temp;
temp = "";
}
else { // == 4
count == 0;
first[firstIndex++].Time = temp; // Здесь сервер указывает на ошибку в этой строке.
temp = "";
}
}
}
count = 0;
Текст ошибки: TypeError: Cannot set property 'Time' of undefined
at /var/www/www-root/data/www/invizzz.com/nodejs/listenMQL.js:498:80
at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3)