This project is read-only.

index()

The index linq operator returns a new linq object that contains a collection of objects where each object has a "key" property and a "value" property. For each object the "key" property is equal to the zero-based index (or "startingIndex"-based index, if the "startingIndex" parameter is given) of the element in the original collection, and the "value" property is equal to the element in the original collection.
var arr = ['a', 'b', 'c', 'd', 'e'];

// col1 = [ {key: 0, value: 'a' },
//          {key: 1, value: 'b' },
//          {key: 2, value: 'c' },
//          {key: 3, value: 'd' },
//          {key: 4, value: 'e' } ]
var col1 = $linq(arr).index().toArray();

// col2 = [ {key: 10, value: 'a' },
//          {key: 11, value: 'b' },
//          {key: 12, value: 'c' },
//          {key: 13, value: 'd' },
//          {key: 14, value: 'e' } ]
var col2 = $linq(arr).index(10).toArray();

Last edited Feb 6, 2015 at 11:13 PM by battousai999, version 2