for-in
loops should include an if
statement JS-0051 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) {
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 }),
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) {
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) {
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) {
Looping over objects with a for in
loop will include properties that are inherited through the prototype chain.
This behavior can lead to unexpected keys in your for loop.
for (const key in foo) {
doSomething(key);
}
for (const key in foo) {
if (Object.prototype.hasOwnProperty.call(foo, key)) {
doSomething(key);
}
}
for (const key of Object.keys(foo)) {
doSomething(key);
}