Given the following array…
'0' ...
'item_id' ...
'parent_id' => "none"
'depth' => "0"
'left' => "1"
'right' => "30"
'1' ...
'item_id' => "1"
'parent_id' ...
'depth' => "1"
'left' => "2"
'right' => "7"
'2' ...
'item_id' => "784657484"
'parent_id' => "1"
'depth' => "2"
'left' => "3"
'right' => "4"
'3' ...
'item_id' => "3"
'parent_id' => "1"
'depth' => "2"
'left' => "5"
'right' => "6"
What would be the best way in javascript to pick off the item_id when the parent_id is empty and put it into another array.
Since your data is pseudo code and not actual javascript, I’m guessing it’s an array of objects (I’ve asked you to clarify, but received no response). So, with that guess this code would create an array of
item_idvalues when theparent_idwas missing or"none":