DEV Community

Discussion on: Why you should stop declaring variables inside a for loop (especially in JavaScript)

Collapse
somedood profile image
Basti Ortiz • Edited on

Whoa, this is crazy. I have always dismissed the declaration inside the loop having a very minimal performance impact. Apparently my assumptions were wrong.

Thanks for this! Will definitely take note of this from here on out.

Collapse
nicolalc profile image
Nicola Author

Thanks a lot! Check this video from Unity, is for C# but some principles could be applied to general programming languages, it shows a lot of data optimization and performance boost using the Data-Driven programming pattern

Collapse
somedood profile image
Basti Ortiz

Thanks! I definitely will watch it.

Collapse
jwkicklighter profile image
Jordan Kicklighter

Whao, this is crazy

That's because it is incorrect. Please read the rest of the comments in this article for better explanations.

Collapse
somedood profile image
Basti Ortiz

Thanks for the heads up!