Issue #2099599 by jantimon: Minor for-loop optimizations for base.js.
Merge pull request #440 from hellomrcat/js-loop

Issue #2099599 by jantimon: Minor for-loop optimizations for base.js.