How to check if the target variable is in an array?

This question already has an answer here:

  • How do you check if a variable is an array in JavaScript? [duplicate] 24 answers

  • you can use indexOf methd of array https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf

    if(doingGood.indexOf(target) !== -1){

    // do something

    }

    链接地址: http://www.djcxy.com/p/19306.html

    上一篇: 如何检测一个变量是否是一个数组

    下一篇: 如何检查目标变量是否在数组中?