Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

sequenceEqual(second[, comparer, arg])

suckgamoni edited this page · 1 revision

Determines whether two sequences are equal by comparing their elements by using a specified equality comparer.

Syntax

Parameters

second

An iterable object to compare to the first sequence.

comparer

Type: function(value1, value2, arg): boolean
An equality comparer to use to compare elements.

arg

An external argument.

Return Value

true if the two source sequences are of equal length and their corresponding elements compare equal according to comparer; otherwise, false.


Example

var pet1 = { name: "Turbo", age: 2 };
var pet2 = { name: "Peanut", age: 8 };

// Create two lists of pets.
var pets1 = [ pet1, pet2 ];
var pets2 = [ pet1, pet2 ];

var equal = from(pets1).sequenceEqual(pets2);

console.log("The lists " + (equal ? "are" : "are not") + " equal.");

/*
 This code produces the following output:

 The lists are equal.
*/
var storeA = [ { name: "apple", code: 9 }, 
               { name: "orange", code: 4 } ];

var storeB = [ { name: "apple", code: 9 }, 
               { name: "orange", code: 4 } ];

var comparer = "#0 == #1 || (#0 && #1 && #0.name == #1.name && #0.code == #1.code)";
var equalAB = from(storeA).sequenceEqual(storeB, comparer);

console.log("Equal? " + equalAB);

/*
    This code produces the following output:

    Equal? true
*/
Something went wrong with that request. Please try again.