2017-08-16 10 views

答えて

9

配列があり、indexOfの機能がありますか?

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

これはクロスブラウザソリューションです。

まあ、includes質問のこの種は、より良いhttps://codereview.stackexchange.com/に頼まれ

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

} 
2
if(["str1", "str2"].indexOf(this.selectedItem.label) !== -1) { 
    // TO DO 
} 
関連する問題