$empty()

Returns an empty iteratable object that has the specified type argument.

Syntax

Return Value

An empty iteratable object.

Examples

var names1 = [ "Hartono, Tommy" ];
var names2 = [ "Adams, Terry", "Andersen, Henriette Thaulow", "Hedlund, Magnus", "Ito, Shu" ];
var names3 = [ "Solanki, Ajay", "Hoeing, Helge", "Andersen, Henriette Thaulow", "Potra, Cristina", "Iallo, Lucio" ];

var namesList = [ names1, names2, names3 ];

// Only include arrays that have four or more elements
var allNames = $from(namesList).aggregateSeed($empty(),
	"(current, next) => next.length > 3 ? current.union(next) : current");

allNames.each("document.writeln($)");

/*
 This code produces the following output:

 Adams, Terry
 Andersen, Henriette Thaulow
 Hedlund, Magnus
 Ito, Shu
 Solanki, Ajay
 Hoeing, Helge
 Potra, Cristina
 Iallo, Lucio
*/

Last edited May 20, 2012 at 1:04 AM by suckgamoni, version 2

Comments

No comments yet.