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

前端 未结 18 1732
粉色の甜心
粉色の甜心 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:23

    var fruits = ["Banana", "Orange", "Apple", "Mango"];
    if(fruits.indexOf("Banana") == -1){
        console.log('item not exist')
    } else {
    	console.log('item exist')
    }

提交回复
热议问题