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

Re: saw 'undefined' (a reserved word)

Expand Messages
  • Douglas Crockford
    ... undefined should have been a reserved word. To avoid confusion, it is best to treat it as such.
    Message 1 of 7 , Dec 16, 2009
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "donavon.west" <donavonwest@...> wrote:
      >
      > In JavaScript/ECMAScript, undefined is NOT a reserved word, but I get the error "Expected an identifier and instead saw 'undefined' (a reserved word)" when JSLinting the following code:
      >
      > function(window, undefined) {

      undefined should have been a reserved word. To avoid confusion, it is best to treat it as such.
    • Douglas Crockford
      ... I don t recommend adopting lousy practices because something might be faster or because jQuery does it. If you can demonstrate a significant performance
      Message 2 of 7 , Dec 16, 2009
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, Aseem Kishore <aseem.kishore@...> wrote:
        >
        > Yeah I've run into that too. I know that jQuery uses that technique, as it
        > allows for munging of the undefined name. I think it might also improve
        > lookup performance but I'm not 100% sure of that. Either way, it would be
        > nice if JSLint allowed that, maybe through an option if you don't want to
        > change the default.

        I don't recommend adopting lousy practices because something
        "might" be faster or because jQuery does it.

        If you can demonstrate a significant performance advantage, I will consider an option.
      • donavon.west
        But the fact remains that undefined is NOT a reserved word yet JSLint erroneously reporting that it is. What I m doing in the example given (which you call
        Message 3 of 7 , Dec 16, 2009
        • 0 Attachment
          But the fact remains that undefined is NOT a reserved word yet JSLint erroneously reporting that it is. What I'm doing in the example given (which you call sloppy code) works perfectly fine, is becoming a common practice and JSLint should allow it.

          If you insist that JSLint call this out, at least change the error message to not state that undefined is a reserved word. I could at least understand and respect that decision.

          Thx,
          Donavon

          BTW, a quick "thx again" for JSLint. I couldn't live without it.


          --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
          >
          > --- In jslint_com@yahoogroups.com, "donavon.west" <donavonwest@> wrote:
          > >
          > > In JavaScript/ECMAScript, undefined is NOT a reserved word, but I get the error "Expected an identifier and instead saw 'undefined' (a reserved word)" when JSLinting the following code:
          > >
          > > function(window, undefined) {
          >
          > undefined should have been a reserved word. To avoid confusion, it is best to treat it as such.
          >
        • samckayak
          ... Sounds like you use JSLint as a syntax checker. Equally important is JSLint s ability to define a safe, reliable, readable subset of JavaScript.
          Message 4 of 7 , Dec 17, 2009
          • 0 Attachment
            --- In jslint_com@yahoogroups.com, "donavon.west" <donavonwest@...> wrote:
            >
            > But the fact remains that undefined is NOT a reserved word yet JSLint erroneously reporting that it is. What I'm doing in the example given (which you call sloppy code) works perfectly fine, is becoming a common practice and JSLint should allow it.
            >

            Sounds like you use JSLint as a syntax checker. Equally important is JSLint's ability to define a safe, reliable, readable subset of JavaScript. Excluding variable names like "undefined" fits into this category of unsafe practices, like excluding "exec()".
          • donavon.west
            Using undefined in such a way is not even remotely in the same ballpark as using exec(). Again undefined is NOT a reserved word. Keep the in JSLint warning if
            Message 5 of 7 , Dec 17, 2009
            • 0 Attachment
              Using undefined in such a way is not even remotely in the same ballpark as using exec(). Again undefined is NOT a reserved word. Keep the in JSLint warning if you must but at least change the error message. "Eval is evil", I get that. It doesn't say "Eval is not a JavaScript function".

              --- In jslint_com@yahoogroups.com, "samckayak" <samc@...> wrote:
              >
              >
              >
              > --- In jslint_com@yahoogroups.com, "donavon.west" <donavonwest@> wrote:
              > >
              > > But the fact remains that undefined is NOT a reserved word yet JSLint erroneously reporting that it is. What I'm doing in the example given (which you call sloppy code) works perfectly fine, is becoming a common practice and JSLint should allow it.
              > >
              >
              > Sounds like you use JSLint as a syntax checker. Equally important is JSLint's ability to define a safe, reliable, readable subset of JavaScript. Excluding variable names like "undefined" fits into this category of unsafe practices, like excluding "exec()".
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.