Skip to content

Conversation

@edwingustafson
Copy link
Contributor

Declare loop variables at first use. Do not redeclare on subsequent uses.

@scottleibrand
Copy link
Contributor

Does this have any effect on whether the variables are reset for nested loops? Or is the presence or absence of var irrelevant for that?

@edwingustafson
Copy link
Contributor Author

No effect since I find each for loop diligently assigning its own initial value.

(To avoid loop variable reuse, some or all of the loops could be rewritten using forEach and the other array methods that take a callback function. That way JavaScript function scope makes each pass a sealed unit.)

@scottleibrand scottleibrand merged commit eebf24a into openaps:dev Dec 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants