синтаксис 'nullishCoalescingOperator' в настоящее время не включен

_findItemByValue (Obj, «start», 4);

var _findItemByValue = function(obj, prop, value) {
  return obj.filter(function(item) {
    return (item[prop] === value);
  });
}

Совместимость со всеми, за исключением IE6, IE7, IE8, но существуют polyfill .

if (!Array.prototype.filter) {
  Array.prototype.filter = function (fn, context) {
    var i,
        value,
        result = [],
        length;

        if (!this || typeof fn !== 'function' || (fn instanceof RegExp)) {
          throw new TypeError();
        }

        length = this.length;

        for (i = 0; i < length; i++) {
          if (this.hasOwnProperty(i)) {
            value = this[i];
            if (fn.call(context, value, i, this)) {
              result.push(value);
            }
          }
        }
    return result;
  };
}

14
задан Mahgol Fa 21 January 2019 в 10:45
поделиться