Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #31911

Get object from one of its values

Newsgroups comp.lang.javascript
From Andrew Poulos <ap_prog@hotmail.com>
Subject Get object from one of its values
Date 2016-12-20 14:43 +1100
Message-ID <W9ednbBeYoFENcXFnZ2dnUU7-RfNnZ2d@westnet.com.au> (permalink)

Show all headers | View raw


If there are one or more objects each of which has a property called 
childArray whose value is always a one dimensional array and elements of 
the array are unique (ie an element cannot also occur in the childArray 
of another object) then if I know the value of one element of a 
childArray how do I find the object it's associated with?

For example if I have:

var a = {};
     a.childArray = [1,2,3,a,b,c,..];
var b = {};
     b.childArray = [4,5,6,d,e,f,...];
var c = {};
     c.childArray = [7,8,9,g,h,i,...];
...

and I'm given the value "5" how do I find that it's associated with "b"?

The code is dynamically created so I don't know beforehand what or how 
many objects will be created.

Andrew Poulos

Back to comp.lang.javascript | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Get object from one of its values Andrew Poulos <ap_prog@hotmail.com> - 2016-12-20 14:43 +1100
  Re: Get object from one of its values Jake Jarvis <pig_in_shoes@yahoo.com> - 2016-12-20 10:42 +0100
    Re: Get object from one of its values Andrew Poulos <ap_prog@hotmail.com> - 2016-12-21 07:25 +1100
  Re: Get object from one of its values Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-20 13:33 +0100
    Re: Get object from one of its values Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-20 23:10 +0100
  Re: Get object from one of its values John Harris <niam@jghnorth.org.uk.invalid> - 2016-12-20 18:21 +0000

csiph-web