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

3139Re: [jslint] init of for

Expand Messages
  • Marcel Duran
    Feb 25, 2013
      That's true, however html collections are considered live which means
      they're automatically updated when the underlying document is changed.

      On Monday, February 25, 2013, Mike On Mobile wrote:

      > **
      >
      >
      > At one time it was considered best practice to store the array length in a
      > local variable and use that in the comparison . That was because the object
      > property lookup was significantly more expensive than using the local
      > variable. However, recent JavaScript engines such as v8 reduce the
      > performance gap so greatly that the benefit of this optimization is
      > negligible. But it still makes a big difference in ie8 iirc.
      >
      > Jonas Trollvik jonas@... <javascript:_e({}, 'cvml',
      > 'jonas%40weightpoint.se');>> wrote:
      >
      > >What is the benefit of caching the array length here?
      > >
      > >I doubt it has any effect on performance.
      > >
      > >function f(an_array) {
      > >'use strict'
      > >var i;
      > >for (i = 0; i < an_array.length; i += 1) {
      > >// operate on an_array[i]
      > >}
      > >}
      > >
      > >looks like it is a lot cleaner and easier to read.
      > >
      > >2013/2/25 Heinz Rasched raschedh@... <javascript:_e({}, 'cvml',
      > 'raschedh%40yahoo.com');>>
      > >
      > >> **
      > >>
      > >>
      > >> I knew that you wouldn't like that.
      > >>
      > >>
      > >> > (; looks like a mistake.
      > >>
      > >> That depends on the context of the `(;'
      > >>
      > >>
      > >> > Do not use forms that look like mistakes.
      > >>
      > >> I do not.
      > >>
      > >>
      > >> > To make it easier to find the needle, make your program look less
      > like a
      > >> haystack.
      > >>
      > >> My programs are far from looking like that.
      > >> I never look for needles in them.
      > >>
      > >> Anyhow, thanks for the consideration.
      > >>
      > >> Of course, I'll pledge myself to JsLint's teachings,
      > >> and will keep on writing
      > >>
      > >> (i = 0, n = heretic.length; [...]
      > >>
      > >>
      > >>
      > >
      > >
      > >[Non-text portions of this message have been removed]
      > >
      > >
      > >
      > >------------------------------------
      > >
      > >Yahoo! Groups Links
      > >
      > >
      > >
      >
      >


      --
      @marcelduran


      [Non-text portions of this message have been removed]
    • Show all 8 messages in this topic