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.
    Your message has been successfully submitted and would be delivered to recipients shortly.