this.ipv4Indx = this.ipv4Indx > -1? this.ipv4Indx : tempData.findIndex((obj => obj.value == "ipv4")) Putting in a condition helped me solve this issue.