Показать сообщение отдельно
  #23 (permalink)  
Старый 11.07.2011, 13:20
sinistral
Посмотреть профиль Найти все сообщения от melky
 
Регистрация: 28.03.2011
Сообщений: 5,418

if( typeof Array.prototype.forEach === 'undefined' )
   Array.prototype.forEach = function (iterator, context) {
    for (var i = 0, length = this.length >>> 0; i < length; i++) {
      if (i in this) iterator.call(context, this[i], i, this);
    }
  }


Prototype.js

я просто с ума от изящества

но зачем делать так ?
this.length >>> 0

Пример: это же Math.floor
alert ( [ "_______","|examples :","_______", "|9 >>> 0", "=> "+ (9 >>> 0), "| 9.8 >>> 0", "=> "+ (9.8 >>> 0), "_______"].join("\n") );


можно было и так, Kolyaj
if( typeof Array.prototype.forEach === 'undefined' )
   Array.prototype.forEach =  function(fn, ctx) {
            for (var i = 0, l = this.length; i < l; i++) 
                       if (i in this)   
                           fn.call(ctx, this[i], i, this);
        };


ну а прерывать как? через метание ?

Последний раз редактировалось melky, 11.07.2011 в 13:29.
Ответить с цитированием