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

Re: Undetected variable

Expand Messages
  • santini.alberto
    ... It is correct because there is an error in the snippet: the body of a for in should be wrapped in an if statement to filter unwanted properties from the
    Message 1 of 4 , Apr 15 8:20 AM
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "Fred Lorrain" <yahoo@...> wrote:
      >
      > The key variable is not detected.

      It is correct because there is an error in the snippet: the body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.

      ...
      for (key in obj) {
      if (obj.hasOwnProperty(key)) {
      objLength++;
      }
      }
      ...

      Regards,
      Alberto
    • Fred Lorrain
      Ok, thank you very much. I should have read your JavaScript recommendations before asking. What a shame .hasOwnProperty() is not documented in many JavaScript
      Message 2 of 4 , Apr 16 1:09 AM
      • 0 Attachment
        Ok, thank you very much.
        I should have read your JavaScript recommendations before asking.

        What a shame .hasOwnProperty() is not documented in many JavaScript references

        --- In jslint_com@yahoogroups.com, "santini.alberto" <albertosantini@...> wrote:
        >
        > --- In jslint_com@yahoogroups.com, "Fred Lorrain" <yahoo@> wrote:
        > >
        > > The key variable is not detected.
        >
        > It is correct because there is an error in the snippet: the body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.
        >
        > ...
        > for (key in obj) {
        > if (obj.hasOwnProperty(key)) {
        > objLength++;
        > }
        > }
        > ...
        >
        > Regards,
        > Alberto
        >
      • Douglas Crockford
        ... Thanks. This has been fixed.
        Message 3 of 4 , Apr 17 10:55 PM
        • 0 Attachment
          --- In jslint_com@yahoogroups.com, "Fred Lorrain" <yahoo@...> wrote:
          > for (key in obj) {

          > The key variable is not detected.

          Thanks. This has been fixed.
        Your message has been successfully submitted and would be delivered to recipients shortly.