This is part 11 of the tutorial series Learn Javascript in Construct . This part continues on from part 10. So in case you missed it, see Learn Javascript in Co...
How can I pick an instance by an instance variable?
Just in case this is still relevant (for anyone with the same question): check out the fairly new example titled "Generator Function" for one way; but using generator functions is not required, you can just do that too:
for (const inst of runtime.objects.SomeObjectType.instances())
{
if (inst.instVars.SomeInstanceVariable === 42) {...}
}