2017-08-16 23 views

cevap

9

dizi ve indexOf fonksiyonu olabilir mi?

if(["str1","str2","str3","str4"].indexOf(this.selectedItem.label) > -1){ 
    // found 
} 

Bu bir çapraz tarayıcı çözümüdür.

Neyse, includes soru bu tür iyi https://codereview.stackexchange.com/ de istenir

if(["str1","str2","str3","str4"].includes(this.selectedItem.label)){ 

} 
2
if(["str1", "str2"].indexOf(this.selectedItem.label) !== -1) { 
    // TO DO 
} 
İlgili konular