Prefer that for-in loops should include an if statement JS-0051
Anti-pattern
Minor
5 months ago3 years old
Wrap the body of a for-in loop in an if statement with a hasOwnProperty guard
 9712            d.__proto__ = b
 9713          }) ||
 9714        function (d, b) {
 9715          for (const p in b) b.hasOwnProperty(p) && (d[p] = b[p]) 9716        })(d, b)
 9717    }
 9718    return function (d, b) {
Wrap the body of a for-in loop in an if statement with a hasOwnProperty guard
 8247  }),
 8248  (e.idf = function (e, t) {
 8249    let r = 0
 8250    for (const i in e) i != '_index' && (r += Object.keys(e[i]).length) 8251    const n = (t - r + 0.5) / (r + 0.5)
 8252    return Math.log(1 + Math.abs(n))
 8253  }),
Wrap the body of a for-in loop in an if statement with a hasOwnProperty guard
 7617    },
 7618    delegateEvents: function (t) {
 7619      if ((t || (t = i.result(this, 'events')), !t)) return this
 7620      for (const e in (this.undelegateEvents(), t)) { 7621        let n = t[e] 7622        if ((i.isFunction(n) || (n = this[n]), n)) { 7623          const r = e.match(P) 7624          this.delegate(r[1], r[2], n.bind(this)) 7625        } 7626      } 7627      return this
 7628    },
 7629    delegate: function (t, e, i) {
Wrap the body of a for-in loop in an if statement with a hasOwnProperty guard
 7132      let r
 7133      const e = this._changing ? this._previousAttributes : this.attributes
 7134      const n = {}
 7135      for (const s in t) { 7136        const a = t[s] 7137        i.isEqual(e[s], a) || ((n[s] = a), (r = !0)) 7138      } 7139      return !!r && n
 7140    },
 7141    previous: function (t) {
Wrap the body of a for-in loop in an if statement with a hasOwnProperty guard
 7121    },
 7122    clear: function (t) {
 7123      const e = {}
 7124      for (const n in this.attributes) e[n] = void 0 7125      return this.set(e, i.extend({}, t, { unset: !0 }))
 7126    },
 7127    hasChanged: function (t) {