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

var a = var b = foo();

Expand Messages
  • Daniel Cassidy
    Hi, JSLint forbids the following form: var a = var b = foo(); // Expected an identifier and instead saw var . Is this intentional? It can occasionally be
    Message 1 of 4 , Dec 16, 2008
    • 0 Attachment
      Hi,

      JSLint forbids the following form:

      var a = var b = foo(); // Expected an identifier and instead saw 'var'.

      Is this intentional? It can occasionally be useful where two variables
      start at the same value and then diverge.

      Dan.
    • Douglas Crockford
      ... Of course.
      Message 2 of 4 , Dec 16, 2008
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "Daniel Cassidy" <mail@...> wrote:
        > JSLint forbids the following form:
        >
        > var a = var b = foo(); // Expected an identifier and instead saw 'var'.
        >
        > Is this intentional?

        Of course.
      • mnewton32@yahoo.ca
        I believe the var declaration is not legal as the right side of a statement; it would require var b to return a value, which it does not. Try: var a, b; a =
        Message 3 of 4 , Dec 16, 2008
        • 0 Attachment
          I believe the var declaration is not legal as the right side of a statement; it would require 'var b' to return a value, which it does not. Try:
          var a, b;
          a = b = foo();

          Sent from my BlackBerry device on the Rogers Wireless Network

          -----Original Message-----
          From: "Douglas Crockford" <douglas@...>

          Date: Tue, 16 Dec 2008 15:00:28
          To: <jslint_com@yahoogroups.com>
          Subject: [jslint] Re: var a = var b = foo();


          --- In jslint_com@yahoogroups.com, "Daniel Cassidy" <mail@...> wrote:
          > JSLint forbids the following form:
          >
          > var a = var b = foo(); // Expected an identifier and instead saw 'var'.
          >
          > Is this intentional?

          Of course.




          [Non-text portions of this message have been removed]
        • Daniel Cassidy
          ... Uhh... sorry. It is of course a syntax error. Chalk that one up to temporary insanity on my part. I was thinking of another language where var b is an
          Message 4 of 4 , Dec 16, 2008
          • 0 Attachment
            2008/12/16 Douglas Crockford <douglas@...>:
            > --- In jslint_com@yahoogroups.com, "Daniel Cassidy" <mail@...> wrote:
            >> JSLint forbids the following form:
            >>
            >> var a = var b = foo(); // Expected an identifier and instead saw 'var'.
            >>
            >> Is this intentional?
            >
            > Of course.

            Uhh... sorry. It is of course a syntax error.

            Chalk that one up to temporary insanity on my part. I was thinking of
            another language where "var b" is an expression, and so returns a
            value (as well as declaring a variable).

            Dan.
          Your message has been successfully submitted and would be delivered to recipients shortly.