sequenceEqual()

The sequenceEqual linq operator returns a boolean value indicating whether the collection is the equal to (i.e., same elements in the same order) the "second" collection. The sequenceEqual operator can also take a "comparer" function that is used to determine equality between elements of the two collections.
var arr1 = [1, 2, 3, 4, 5];
var arr2 = [1, 2, 3, 4, 5];

var arr3 = ['one', 'two', 'three', 'four'];
var arr4 = ['ONE', 'TWO', 'THREE', 'FOUR'];

// val1 = true
var val1 = $linq(arr1).sequenceEqual(arr2);

// val2 = true
var val2 = $linq(arr3).sequenceEqual(arr4, 
    "(x, y) => x.toLowerCase() == y.toLowerCase()");

sequenceEquivalent()

The sequenceEquivalent linq operator returns a boolean value indicating whether the collection is equivalent to the "second" collection (that is, has the same elements regardless of order). The sequenceEquivalent operator can also take a "comparer" function that is used to determine equality between elements of the two collections.
var arr1 = [1, 2, 3, 4, 5];
var arr2 = [5, 4, 3, 2, 1];

var arr3 = ['one', 'two', 'three', 'four'];
var arr4 = ['FOUR', 'ONE', 'TWO', 'THREE'];

// val1 = true
var val1 = $linq(arr1).sequenceEquivalent(arr2);

// val2 = true
var val2 = $linq(arr3).sequenceEquivalent(arr4, 
    "(x, y) => x.toLowerCase() == y.toLowerCase()");

Last edited Dec 19, 2012 at 7:19 AM by battousai999, version 6