Search array of objects

Giganews Newsgroups
Subject: Search array of objects
Posted by:  Andrew Poulos (ap_pr…@hotmail.com)
Date: Mon, 24 Feb 2020

I have an array of 50+ arrays each containing 300+ objects as elements.
Each individual object looks like

{
  type: "text",
  id: "text01",
  content: "Turn to left",
  disabled: false,
  bg: "small.jpg"
}

So the entire array looks like

[
  [obj1, obj2, obj3...],
  [obj1, obj2, obj3...],
  [obj1, obj2, obj3...],
  ...
]

That is, every sub-array has the same number of objects: 'content',
'disabled' and 'bg' may differ from sub-array to sub-array.

I need to change the value of 'bg' for the "same" five objects across
all the sub-arrays.

Currently I'm looping through the top level array and then each object
in a sub-array looking for the objects in question. Is there a more
efficient way to do this without looping?

Andrew Poulos

Replies