Skip to content

Instantly share code, notes, and snippets.

@petermichaux
petermichaux / gist:1830345
Created February 14, 2012 20:53
using constructor
function Set() {
this._elements = [];
}
Set.prototype.filter = function(fn) {
var result = new this.constructor();
for (var i = 0; i < this._elements.length; i++) {
if (fn(this._elements[i]) {
result.add(this._elements[i]);
}