for-in
loops should include an if
statement JS-00511227 WordCloud.minFontSize = minFontSize
1228 WordCloud.stop = function stop () {
1229 if (timer) {
1230 for (var timerId in timer) {1231 window.clearImmediate(timer[timerId])1232 }1233 }
1234 }
1235
846 span.style[cssProp] = styleRules[cssProp]
847 }
848 if (attributes) {
849 for (var attribute in attributes) { 850 span.setAttribute(attribute, attributes[attribute]) 851 } 852 }
853 if (classes) {
854 span.className += classes
842 styleRules.color = color
843 }
844 span.textContent = word
845 for (var cssProp in styleRules) { 846 span.style[cssProp] = styleRules[cssProp] 847 } 848 if (attributes) {
849 for (var attribute in attributes) {
850 span.setAttribute(attribute, attributes[attribute])
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);
}