Skip to content

Array.prototype.some

jerryzhang edited this page Jan 31, 2023 · 1 revision

title: Array.prototype.some url: https://www.yuque.com/endday/blog/vwvbzl

if (!Array.prototype.some) {
  Array.prototype.some = function (fun /*, thisp */) {
    if (this === void 0 || this === null) { throw TypeError(); }
    var t = Object(this);
    var len = t.length >>> 0;
    if (typeof fun !== "function") { throw TypeError(); }
    var thisp = arguments[1], i;
    for (i = 0; i < len; i++) {
      if (i in t && fun.call(thisp, t[i], i, t)) {
        return true;
      }
    }
    return false;
  };
}
Clone this wiki locally