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

2046Re: [jslint] Re: has not been fully defined yet

Expand Messages
  • Kent Davidson
    Mar 10, 2011
    • 0 Attachment
      On Mar 10, 2011, at 9:55 AM, John Hawkinson wrote:

      > but why bother to initialize foo to null? The truthiness of null and
      > and undefined is the same...

      True, it's not necessary in this case.

      > > My point previously was that regardless of warnings or not, if a
      > > small tweak in my code will eliminate the warning, I err on the side
      > > of just making the cosmetic change, even if I know the warning
      >
      > Looks like you didn't finish that sentence...

      I err on the side of just making the cosmetic change, even if I know the warning is not really going to affect the code.

      > I do have to say, it makes me sad that the in the name of avoiding standalone
      > expressions, we have to add an extra level of braces that make the code
      > harder to read.

      Anonymous functions are generally hard to read, esp. when on the same line. I use http://prettydiff.com if presented with something which is hard to read. It's another awesome tool to make code more readable.

      foo && foo.m()

      is a nice construct, but the assumption is that jslint is trying to avoid the issue where you want to assign something, but forgot to. So,

      var x = foo && foo.m();

      validates, but

      foo && foo.m()

      doesn't. It could be an error if you actually did want to use the expression result, which && returns.

      And:

      if (foo) {
      foo.m();
      }

      returns nothing, which is what is wanted in this case.

      As for harder to read, we're really nitting picks at this point.

      Cheers,

      -Kent.
      --
      Kent Davidson
      Market Ruler, LLC
      Marketing Power Tools
      http://marketruler.com/?_cr=efoot
      +1 866-622-8636 x88



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