Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From what I understand, you want to get all arrays in new_dataArray that are not in old_dataArray and I'm assuming that if the first element in each (the 'id-n' element) is the same, then so is the rest of the array. You can do so like this:</p> <pre><code>// create an array to store our results: var results = new Array(); // loop through new_dataArray: outerloop: for (var i = 0; i &lt; new_dataArray.length; ++i) { // loop through old_dataArray to compare the i'th element // in new_dataArray with each in old_dataArray: for (var j = 0; j &lt; old_dataArray.length; ++j) { // check if the ids are the same if (new_dataArray[i][0] == old_dataArray[j][0]) // yes it's there, so move on to the next element of new_dataArray continue outerloop; } // if we get here, continue outerloop; was never called so // this element is not in old_dataArray results.push(new_dataArray[i]); } // now results contains all arrays that are in new_dataArray // but not in old_dataArray </code></pre> <p>EDIT: If, however, you want ALL the elements in each array to be equal, not just the first (id-n) element, use this:</p> <pre><code>// create an array to store our results: var results = new Array(); // loop through new_dataArray: outerloop: for (var i = 0; i &lt; new_dataArray.length; ++i) { // loop through old_dataArray to compare the i'th element // in new_dataArray with each in old_dataArray: innerloop: for (var j = 0; j &lt; old_dataArray.length; ++j) { // check if the arrays are the same size: if (new_dataArray[i].length != old_dataArray[j].length) // no, so they must be different continue innerloop; // check if the arrays have the same values for (var k = 0; k &lt; old_dataArray[j].length; ++k) { if (new_dataArray[i][k] != old_dataArray[j][k]) // the k'th element is different continue innerloop; } // if we get here, then we have found a match, so move on continue outerloop; } // if we get here, continue outerloop; was never called so // this element is not in old_dataArray results.push(new_dataArray[i]); } // now results contains all arrays that are in new_dataArray // but not in old_dataArray </code></pre>
    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. This table or related slice is empty.
    1. 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