Loading ...
Sorry, an error occurred while loading the content.

2878Re: Nested loops with the same control vars

Expand Messages
  • Chris
    May 10, 2012
    • 0 Attachment
      I agree: I think such a rule would be a useful improvement to JSLint. I have seen this sort of situation causing numerous bugs in my own code. Of course, we have discussed this before:


      Also, some time later, I found a bug in JSLint itself that was caused by this coding practice:

      When you have nested scopes, the idea of declaring variables in an outer scope and redeclaring them in an inner scope is naturally confusing. I argue that any code written in this way could be written more clearly by giving the variables distinct names.

      - Chris

      --- In jslint_com@yahoogroups.com, "Rob Richardson" <erobrich@...> wrote:
      > I think an even larger issue should be checking for identically named
      > variables declared in different scope. This too should be illegal:
      > function a() {
      > ````var i;
      > ````function b() {
      > ````````var i;
      > ````};
      > };
    • Show all 5 messages in this topic