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

var a = b = "c"; Stopping, unable to continue

Expand Messages
  • marc_hunter
    Just came across some code which was overriding some functionality from the jquery datepicker. The code uses this construct: var a = b = c; which happens to
    Message 1 of 2 , Mar 23 6:41 AM
    • 0 Attachment
      Just came across some code which was overriding some functionality from the jquery datepicker. The code uses this construct:

      var a = b = c;

      which happens to gum up the jslint parser.


      This works:

      function bob()
      {
      var b = "C";
      var a;
      a = b = "b";
      return a;
      }

      This doesn't:

      function bob()
      {
      var b = "C";
      var a = b = "b";
      return a;
      }

      I'm not saying I like the approach, just noting that what appears to be syntactically correct js is halting the parser.

      Fwiw,

      Marc
    • Douglas Crockford
      ... That form is confusing because many people expect that b is also declared, but it is not, so b becomes a global variable. To disambiguate, write it as var
      Message 2 of 2 , Mar 23 6:51 AM
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "marc_hunter" <yahoo@...> wrote:
        >
        > Just came across some code which was overriding some functionality from the jquery datepicker. The code uses this construct:
        >
        > var a = b = c;
        >
        > which happens to gum up the jslint parser.

        That form is confusing because many people expect that b is also declared, but it is not, so b becomes a global variable. To disambiguate, write it as

        var a = (b = c);
      Your message has been successfully submitted and would be delivered to recipients shortly.