Skip to content

Instantly share code, notes, and snippets.

View zaparker's full-sized avatar

Zachary Parker zaparker

View GitHub Profile
@zaparker
zaparker / array.extend.js
Last active January 27, 2016 04:41
Based on the LINQ extensions for C# IEnumerables, these functions extend the base JavaScript Array object with new methods for chaining together array operations. Also includes some examples and tests.
// performs the specified action on each item in the array
Array.prototype.forEach = function (fnAction) {
var l = this.length;
for (var i = 0; i < l; ++i) {
fnAction(this[i]);
}
}
// returns an array containing the items matching the filter
Array.prototype.where = function (fnFilter) {