Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Because data.length is only 2 in both cases</p> <p>Further explained: </p> <p>Each object contains multiple values, however, you're not calling for the length of those objects.</p> <p>data.length = get me the count of children in data (not grandchildren and cousins and neices and nephews) JUST CHILDREN.</p> <p>In both of those cases, regaurdless of what the objects are, there is 2 of them in data, thus the length = 2</p> <p>To furter:</p> <p>It doesn't matter what those objects are, heck you could have one string and one child array, that would still return 2 because it would be 2 objects inside the object we're asking for length on</p> <blockquote> <p><strong>UPDATE</strong> <em>to answer second question brought up</em></p> </blockquote> <p>The reason for access is simple, in the first instance, your children are typical Objects, as seen in your example:</p> <pre><code>data = [ // These two CHILDREN are Typical Objects Object { code="6", id="1073148", key="82628835"}, Object { code="17", id="2073140", key="83628837"} ] </code></pre> <p>Thus you can access obect 1 as data[0].</p> <p><em>HOWEVER</em> in your second example, the children are <strong>ARRAY</strong> Type Objects, thus, each child could have multiple values. For Example:</p> <pre><code>data = [ [Object { code="6", id="1073148", key="82628835"}], [Object { code="17", id="2073140", key="83628837"}] ] // Your example here has 2 children but each child is an ARRAY type Object, // Each array has one child which is the object in each one // thus you can call data[0][0] &amp; data[1][0] // Could also be data = [ [Object { code="6", id="1073148", key="82628835"}, Object { code="17", id="2073140", key="83628837"}] ] // in this later case, there is only one child // this one child, like in your example, is an ARRAY, but in this later example, // it has TWO children of its own // thus you can call data[0][0] and data[0][1] </code></pre> <p>As you can see, your second example does NOT have two children OBJECTS, instead it contains 2 Children ARRAYS that each contain one child object. Thus the need to get object 1 becomes <code>data[0][0]</code></p> <p>Where data[0] is getting the first array child and the second [0] is getting that arrays child object</p> <p>Get it?</p> <p>If not just let me know!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload