I have a typescript class and it has a member function and a member variable. Before a forEach loop, I can check the this pointer and it is valid. Inside the loop, when I refer to it, it is null.
public getTypes(vitalsModel) : Array<any> {
    var vitals = _.get(vitalsModel, 'data');
    if (_.isEmpty(vitals) || !_.isArray(vitals)) {
        return [];
    }
    // the this pointer is valid
    _.forEach(vitals, function (vital) {
        let setting = _.get(vitalsModel, key);
        // here the this pointer is null.
        this.generalSettings.push(setting);
        console.log(keys);
        rows.push(keys);
        loc++;
    });
    return rows;
}
Can anyone explain this to me?
 
    