Expand Minimize

Consider to not reference child methods, or values in a for loop sequence

This is a performance penalty, as this will generate a lookup during every loop

CheckId SPC228901
TypeName NoObjectLookupOrMethodCallsInsideForLoops
Severity Information
Type JavaScriptFile

Assign the length/count value to a variable externally to the loop.
Bad Practice

for(var i = 0; i < foo.length; i++) {
  foo[i] = i;

Good Practice
var fooLength = foo.Length;
for(var i = 0; i < fooLength; i++) {
  foo[i] = i;

Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.