forEach with array element Javascript
declare interface ProfileInfoDto {
addrtype: string,
city: string,
state: string,
street: string,
zipcode: string,
}
private profileField(data: ProfileInfoDto[]) {
data.forEach((element: ProfileInfoDto) => {
if (element.addrtype === this.COMMON_CONSTANT) {
this.fillDataWithElementID(this.$component.find('.common-form-container'), element);
} else {
this.fillDataWithElementID(this.$component.find('.detail-form-container'), element);
}
});
}
or /** --- */
private profileField = (data: ProfileInfoDto[]):void => {
data.forEach((element: ProfileInfoDto) => {
if (element.addrtype === this.COMMON_CONSTANT) {
this.fillDataWithElementID(this.$component.find('.common-form-container'), element);
} else {
this.fillDataWithElementID(this.$component.find('.detail-form-container'), element);
}
});
};