How to check if array element exists or not in javascript?

前端 未结 18 1693
粉色の甜心
粉色の甜心 2020-12-07 10:05

I am working with Titanium, my code looks like this:

var currentData = new Array();

if(currentData[index]!==\"\"||currentData[index]!==null||currentData[ind         


        
18条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-07 10:45

    If you are looking for some thing like this.

    Here is the following snippetr

    var demoArray = ['A','B','C','D'];
    var ArrayIndexValue = 2;
    if(demoArray.includes(ArrayIndexValue)){
    alert("value exists");
       //Array index exists
    }else{
    alert("does not exist");
       //Array Index does not Exists
    }

提交回复
热议问题