This might not really be an answer, but I suggest you to check out linq.js. So yes, there is already an implementation of this and you can look at the code to compare and it will help the "learning purposes" you're aiming for.
ExempleExample implementation of anyany
:
// Overload:function()
// Overload:function(predicate)
Enumerable.prototype.any = function (predicate) {
predicate = Utils.createLambda(predicate);
var enumerator = this.getEnumerator();
try {
if (arguments.length == 0) return enumerator.moveNext(); // case:function()
while (enumerator.moveNext()) // case:function(predicate)
{
if (predicate(enumerator.current())) return true;
}
return false;
}
finally {
Utils.dispose(enumerator);
}
};
I personally don't have the required experience in JavaScript to give you my opinion on your implementation. Good luck !