Urgent!how to show data with the same id?

hi
i recently working on a project
i need to create hard code first of list of element
something like the below of code but i not sure if i declare this array correctly?

var it = [{ “id”: “1001”, “type”: “Regular” },{ “id”: “1002”, “type”: “Chocolate” },{ “id”: “1002”, “type”: “Blueberry” },{ “id”: “1004”, “type”: “Devil’s Food” }]

secondly, i want to show all the data that have same id…so how should do ?
must i for loop and if loop…cause i know need to if loop…is it meaning using continue statement
i need to show in when i click on a link and those with the same id will display in the dialog

can show any example
PS…reply asap!!!
thanks!!!

Here is a simple JS script that shows each of the elments of the object array. Please note that I have changed your “id” to “idd” to avoid confusion.

var it = [{ “idd”:“1001”, “type”:“Regular” },{ “idd”:“1002”, “type”:“Chocolate” },{ “idd”:“1002”, “type”:“Blueberry” },{ “idd”:“1004”, “type”:“Devil’s Food” }]
for(var i=0;i<it.length;i++)
{ alert(it[i].idd)}