JS小技巧

1,让一个object支持数组遍历函数的写法:

['filter','forEach','every','map','some'].forEach(function(name){

    Collection.prototype[name]=function(){

        returnArray.prototype[name].apply(this._items, arguments);

    }

});

2,遍历对象时为什么要加hasOwnPropertyOf()?为了判断false之类的属性值。

posted @ 2012-10-29 22:29  yunfan85  阅读(189)  评论(0编辑  收藏  举报