In javascript you have arrays (lists) and objects (maps).
Literary versions are as follows:
var mylist = [1,2,3]; // array var mymap = { car: 'porche', hp: 300, seats: 2 }; // object
if you find out if a value exists in the array, just flip it:
for(var i=0,len=mylist.length;i<len;i++) { if(mylist[i] == 2) {
if you find out if the card has a certain key or has a key with a certain value, all you have to do is access it as follows:
if(mymap.seats !== undefined) { //the key 'seats' exists in the object } if(mymap.seats == 2) { //the key 'seats' exists in the object and has the value 2 }
source share