Skip to content
This repository
Browse code

Array.each chains to keep consistency with the rest of our array methods

  • Loading branch information...
commit 16fd136c59ce6ee17612863132ef386be3ec968f 1 parent 0ed93d4
Scott Kyle authored May 10, 2010

Showing 1 changed file with 12 additions and 6 deletions. Show diff stats Hide diff stats

  1. 18  Source/Core/Core.js
18  Source/Core/Core.js
@@ -294,15 +294,21 @@ Object.extend('forEach', function(object, fn, bind){
294 294
 
295 295
 Object.each = Object.forEach;
296 296
 
297  
-Array.implement('forEach', function(fn, bind){
298  
-	for (var i = 0, l = this.length; i < l; i++){
299  
-		if (i in this) fn.call(bind, this[i], i, this);
  297
+Array.implement({
  298
+	
  299
+	forEach: function(fn, bind){
  300
+		for (var i = 0, l = this.length; i < l; i++){
  301
+			if (i in this) fn.call(bind, this[i], i, this);
  302
+		}
  303
+	},
  304
+	
  305
+	each: function(fn, bind){
  306
+		Array.forEach(this, fn, bind);
  307
+		return this;
300 308
 	}
  309
+	
301 310
 });
302 311
 
303  
-Array.each = Array.forEach;
304  
-Array.prototype.each = Array.prototype.forEach;
305  
-
306 312
 // Array & Object cloning, Object merging and appending
307 313
 
308 314
 var cloneOf = function(item){

0 notes on commit 16fd136

Please sign in to comment.
Something went wrong with that request. Please try again.