Compare Revisions

Array.prototype.filter()

Revision 457007:

Revision 457007 by mattbasta on

Revision 457011:

Revision 457011 by mattbasta on

Title:
Array filter method
Array filter method
Slug:
Web/JavaScript/Reference/Global_Objects/Array/filter
Web/JavaScript/Reference/Global_Objects/Array/filter
Tags:
"ECMAScript5","Array","Array methods","JavaScript 1.6"
"ECMAScript5","Array","Array methods","JavaScript 1.6"
Content:

Revision 457007
Revision 457011
n100    if (this == null) {n100    if (!this) {
n104    var t = Object(this),n104    var objects = Object(this);
105        len = t.length >>> 0,105    var len = objects.length >>> 0;
106        res, thisp, i, val;
t111    res = [];t110    var res = [];
112    thisp = arguments[1];111    var thisp = arguments[1];
113    for (i = 0; i < len; i++) {112    for (var i in objects) {
114      if (i in t) {113      if (objects.hasOwnProperty(i)) {
115        val = t[i]; // in case fun mutates this
116        if (fun.call(thisp, val, i, t)) {114        if (fun.call(thisp, objects[i], i, objects)) {
117          res.push(val);115          res.push(objects[i]);

Back to History