I'm using JavaScript/Client Object Model to retreive some data by CAML query.

I've 2 CAML queries. One retrieve all data from a specified column. The other query retrieve data from same column filtered by a specified date range.

Now, I've this two array (somewhere) in collListItem (filtered data) and collListItem2 (all data) objects.

I would like to compare these objects (that contain arrays) and create another array returning the difference.

Is it possible? And how?

PS: I followed this: http://msdn.microsoft.com/en-us/library/hh185007(v=office.14).aspx so I'm here at the moment:

function onQuerySucceeded(sender, args) {

var listItemInfo = '';
var listItemEnumerator = collListItem2.getEnumerator();

while (listItemEnumerator.moveNext()) {
    var oListItem = listItemEnumerator.get_current();


Example of returned array (array 3)

Array 1 = [A; B; C; D; E]

Array 2 = [B; C]

Array 3 = [A; D; E]

My problem is also accessing to the array in collListItem that in console.log is like:

SP.ListItemCollection {$0_0: SP.ClientContext, $4_0: SP.ClientObjectData, $p_1: null, $2_1: Array[3], $19_1: true…}


  • What would the outcome of the difference array be and in what type? Should it contain unique elements (in A but not in B and in B but not in A) or something else? Please edit your question and it would be possible to answer this question. On StackOverflow there are a lot of questions on comparing arrays, such as this one: stackoverflow.com/a/11025920/286244 – Benny Skogberg Jan 2 '14 at 14:52
  • I would assume your array would have some code like foreach(item i in array){ if(array1.Contains(i)){ DifferenceList.add(i);}} – Mike Jan 2 '14 at 15:19
  • Ok thanks, but how to access to the array in collListItem? – Pepozzo Jan 2 '14 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.