toArray()

suckgamoni edited this page May 15, 2013 · 1 revision

Creates an array from an iterable object.

Syntax

Return Value

An array that contains the elements from the input sequence.


Example

var packages = [
    { company: "Coho Vineyard", weight: 25.2 },
    { company: "Lucerne Publishing", weight: 18.7 },
    { company: "Wingtip Toys", weight: 6.0 },
    { company: "Adventure Works", weight: 33.8 } ];

var companies = from(packages).select("$company").toArray();

for (var i = 0; i < companies.length; ++i) {
	console.log(companies[i]);
}

/*
This code produces the following output:

Coho Vineyard
Lucerne Publishing
Wingtip Toys
Adventure Works
*/