javascript function inArray

前端 未结 5 1694
南方客
南方客 2020-11-28 13:52

I need a javascript function that can take in a string and an array, and return true if that string is in the array..

 function inArray(str, arr){
   ...
 }
         


        
5条回答
  •  囚心锁ツ
    2020-11-28 14:30

    you can use arr.indexOf()

    http://www.w3schools.com/jsref/jsref_indexof_array.asp

提交回复
热议问题