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

Re: JSLint does not allow commas inside of arrays

Expand Messages
  • pauanyu
    ... Thank you. Actually, I would never write such garrish code (normally). Allow me to explain my use case (and how I found out about this): I have a function
    Message 1 of 7 , Sep 7, 2009
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "douglascrockford" <douglas@...> wrote:
      >
      > JSLint will now continue after an extra comma in an array literal.
      > But I still recommend that you fix your code.
      >

      Thank you.

      Actually, I would never write such garrish code (normally). Allow me to explain my use case (and how I found out about this):

      I have a function that converts a string into an array. For instance, the string "[0, 1, 2, 3, 4]" gets converted into the array [0, 1, 2, 3, 4].

      It needs to be able to handle a variety of situations; strings, booleans, numbers, etc. So I wrote a bunch of unit tests to verify that it is working properly. They have already helped me catch a couple regressions.

      The goal of the function was to convert the string as accurately as possible, so if you pass in the string "[,,,]" you should get back the array [,,,]. I had a unit test that verified that commas in the string would properly get converted to commas in the array.

      When running these unit tests in JSLint, I stumbled upon the error, hence this post.
    • pauanyu
      ... You are quite right. I meant to say There are times where you wish to leave the value of particular indices of an array as undefined.
      Message 2 of 7 , Sep 7, 2009
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, Paul Novitski <paul@...> wrote:
        >
        > I imagine this was just a typo but just in case it wasn't I'll point
        > out that it's not the indices here that are undefined, it's the
        > values. The indices for the array above are consecutive integers 0-6.
        >
        > Regards,
        >
        > Paul
        > __________________________
        >
        > Paul Novitski
        > Juniper Webcraft Ltd.
        > http://juniperwebcraft.com
        >

        You are quite right. I meant to say "There are times where you wish to leave the value of particular indices of an array as undefined."
      Your message has been successfully submitted and would be delivered to recipients shortly.