0

I have a multidimensional array, where I'd like to check if a value is in it. I've tried Array.includes("value"), but nothing came up. This is my code:

var database = [{
 "identifier": "test1",
 "extra": "information1"
},{
 "identifier": "test2",
 "extra": "information2"
},{
 "identifier": "test3",
 "extra": "information3"
}
]

How do I test if "identifier" is in my array?
Thank you!

Carcigenicate
  • 43,494
  • 9
  • 68
  • 117
NETDev
  • 139
  • 11

1 Answers1

-1

hi see below code which read each element of your database and print "identifier" value of each element.

var database = [{
 "identifier": "test1",
 "extra": "information1"
},{
 "identifier": "test2",
 "extra": "information2"
},{
 "identifier": "test3",
 "extra": "information3"
}
]

$.each(database, function(index, value) {

if(value.identifier.length>0)
  console.log(value.identifier);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>