javascript function inArray

前端 未结 5 1696
南方客
南方客 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:25

    careful:

    indexOf() uses partial data. if you have '12', '1'

    indexOf('1') will get you the index of '12' not '1'

提交回复
热议问题