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

Re: [jslint] Also unfiltered 'in' expressions?

Expand Messages
  • Douglas Crockford
    ... I was talking about the -in- infix operator. This confusion is another justification for getting rid of it.
    Message 1 of 8 , Feb 23 6:20 PM
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, Rob Richardson <erobrich@...> wrote:

      > I agree -in- is quite dangerous, but how would one enumerate an object's
      > properties without it?

      I was talking about the -in- infix operator. This confusion is another justification for getting rid of it.
    • bluflonalgul
      I think there is this case where the for in loops on a object used as a record. Does it makes sense here to had such tests mentioned in your option.forin ?
      Message 2 of 8 , Feb 24 1:41 AM
      • 0 Attachment
        I think there is this case where the 'for in' loops on a object used as a record.
        Does it makes sense here to had such tests mentioned in your option.forin ?

        tools={
        steps: {
        init: {desc: "blabla", time: 1 },
        done: {desc: "blabla", time: 0 },
        fast: {desc: "blabla", time: 0 },
        },

        // setCurrentStep(step) sets time to a timestamp : steps[step].time= 6544654

        getCurrentStep: function getCurrentStep(){
        var curStep=null;
        var maxTime=0;
        for ( var step in tools.steps ){
        if ( maxTime < tools.steps[step].time ){
        maxTime= tools.steps[step].time;
        curStep= step;
        }
        }
        return curStep;
        },

        }
      • Douglas Crockford
        ... Yes, because some third party code could insert something into Object.prototype without your knowledge and approval. So program defensively, so that your
        Message 3 of 8 , Feb 24 5:41 AM
        • 0 Attachment
          --- In jslint_com@yahoogroups.com, "bluflonalgul" <bluflonalgul@...> wrote:

          > I think there is this case where the 'for in' loops on a object used as a record.
          > Does it makes sense here to had such tests mentioned in your option.forin ?


          Yes, because some third party code could insert something into Object.prototype without your knowledge and approval. So program defensively, so that your code will always perform correctly.
        Your message has been successfully submitted and would be delivered to recipients shortly.