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

For in filter

Expand Messages
  • Ezequiel
    Because I m using my own function for the if statement, this doesn t work: example: var isOwnProperty, object, i; isOwnProperty = function(object, key) {....};
    Message 1 of 6 , Mar 8, 2011
    • 0 Attachment
      Because I'm using my own function for the if statement, this doesn't work:

      example:

      var isOwnProperty, object, i;

      isOwnProperty = function(object, key) {....};

      object = {zero: 0};

      for (i in object) {
      if (isOwnProperty(object, i)) {
      ...
      }
      }

      However, it works if my if statement was something like... object.hasOwnProperty(i);
    • Douglas Crockford
      ... You turned on the forin option. You can not do that.
      Message 2 of 6 , Mar 9, 2011
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "Ezequiel" <thehungerforce@...> wrote:
        >
        > Because I'm using my own function for the if statement, this doesn't work:
        >
        > example:
        >
        > var isOwnProperty, object, i;
        >
        > isOwnProperty = function(object, key) {....};
        >
        > object = {zero: 0};
        >
        > for (i in object) {
        > if (isOwnProperty(object, i)) {
        > ...
        > }
        > }
        >
        > However, it works if my if statement was something like... object.hasOwnProperty(i);


        You turned on the forin option. You can not do that.
      • Ezequiel
        ... No, I did not have any options turned on when I ran that snippet.
        Message 3 of 6 , Mar 9, 2011
        • 0 Attachment
          --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
          >
          > --- In jslint_com@yahoogroups.com, "Ezequiel" <thehungerforce@> wrote:
          > >
          > > Because I'm using my own function for the if statement, this doesn't work:
          > >
          > > example:
          > >
          > > var isOwnProperty, object, i;
          > >
          > > isOwnProperty = function(object, key) {....};
          > >
          > > object = {zero: 0};
          > >
          > > for (i in object) {
          > > if (isOwnProperty(object, i)) {
          > > ...
          > > }
          > > }
          > >
          > > However, it works if my if statement was something like... object.hasOwnProperty(i);
          >
          >
          > You turned on the forin option. You can not do that.
          >

          No, I did not have any options turned on when I ran that snippet.
        • spence.randall@ymail.com
          The Tolerate unfiltered forin is off by default, so you would want to check the appropriate box in Options or add /*jslint forin: true */, then you will no
          Message 4 of 6 , Mar 9, 2011
          • 0 Attachment
            The "Tolerate unfiltered forin" is off by default, so you would want to check the appropriate box in Options or add /*jslint forin: true */, then you will no longer receive the warning.

            - Randall

            --- In jslint_com@yahoogroups.com, "Ezequiel" <thehungerforce@...> wrote:
            >
            >
            > --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@> wrote:
            > >
            > > --- In jslint_com@yahoogroups.com, "Ezequiel" <thehungerforce@> wrote:
            > > >
            > > > Because I'm using my own function for the if statement, this doesn't work:
            > > >
            > > > example:
            > > >
            > > > var isOwnProperty, object, i;
            > > >
            > > > isOwnProperty = function(object, key) {....};
            > > >
            > > > object = {zero: 0};
            > > >
            > > > for (i in object) {
            > > > if (isOwnProperty(object, i)) {
            > > > ...
            > > > }
            > > > }
            > > >
            > > > However, it works if my if statement was something like... object.hasOwnProperty(i);
            > >
            > >
            > > You turned on the forin option. You can not do that.
            > >
            >
            > No, I did not have any options turned on when I ran that snippet.
            >
          • Ezequiel
            I don t want to tolerate unfiltered forins, though.
            Message 5 of 6 , Mar 20, 2011
            • 0 Attachment
              I don't want to tolerate unfiltered forins, though.

              --- In jslint_com@yahoogroups.com, "spence.randall@..." <randall@...> wrote:
              >
              >
              >
              >
              >
              >
              > The "Tolerate unfiltered forin" is off by default, so you would want to check the appropriate box in Options or add /*jslint forin: true */, then you will no longer receive the warning.
              >
              > - Randall
              >
              > --- In jslint_com@yahoogroups.com, "Ezequiel" <thehungerforce@> wrote:
              > >
              > >
              > > --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@> wrote:
              > > >
              > > > --- In jslint_com@yahoogroups.com, "Ezequiel" <thehungerforce@> wrote:
              > > > >
              > > > > Because I'm using my own function for the if statement, this doesn't work:
              > > > >
              > > > > example:
              > > > >
              > > > > var isOwnProperty, object, i;
              > > > >
              > > > > isOwnProperty = function(object, key) {....};
              > > > >
              > > > > object = {zero: 0};
              > > > >
              > > > > for (i in object) {
              > > > > if (isOwnProperty(object, i)) {
              > > > > ...
              > > > > }
              > > > > }
              > > > >
              > > > > However, it works if my if statement was something like... object.hasOwnProperty(i);
              > > >
              > > >
              > > > You turned on the forin option. You can not do that.
              > > >
              > >
              > > No, I did not have any options turned on when I ran that snippet.
              > >
              >
            • Ezequiel
              I remember reading JSLint s source and seeing a is_own function to filter forins. Apparently, it seems Crockford has switched to actually writing
              Message 6 of 6 , Mar 20, 2011
              • 0 Attachment
                I remember reading JSLint's source and seeing a is_own function to filter forins.

                Apparently, it seems Crockford has switched to actually writing Object.hasOwnProperty.call out every single time and jslint followed accordingly. Okay.


                --- In jslint_com@yahoogroups.com, "Ezequiel" <thehungerforce@...> wrote:
                >
                > Because I'm using my own function for the if statement, this doesn't work:
                >
                > example:
                >
                > var isOwnProperty, object, i;
                >
                > isOwnProperty = function(object, key) {....};
                >
                > object = {zero: 0};
                >
                > for (i in object) {
                > if (isOwnProperty(object, i)) {
                > ...
                > }
                > }
                >
                > However, it works if my if statement was something like... object.hasOwnProperty(i);
                >
              Your message has been successfully submitted and would be delivered to recipients shortly.