sequenceEqual(second[, comparer, arg])

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

Syntax

Parameters

second
An iteratable 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.

Examples

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);

document.writeln("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);

document.writeln("Equal? " + equalAB);

/*
	This code produces the following output:

	Equal? true
*/

Last edited May 18, 2012 at 10:01 AM by suckgamoni, version 1

Comments

No comments yet.