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

too strict ! : new Array(5)

Expand Messages
  • montago_2004
    JSLINT is too strict ! var a = new Array(5); creates an empty array of length 5. what the heck is wrong with that code ? if i need an empty array then I m
    Message 1 of 2 , Jul 31, 2008
    • 0 Attachment
      JSLINT is too strict !


      var a = new Array(5);

      creates an empty array of length 5.
      what the heck is wrong with that code ?


      if i need an empty array then I'm forced to use

      var a = [,,,,];

      then what do i do, if i need to create a dynamic, variable length,
      empty array ???
    • Douglas Crockford
      ... new Array does not do what you think it does. Part of JSLint s mission is to help you discover where your reasonable expectations about JavaScript are
      Message 2 of 2 , Jul 31, 2008
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "montago_2004" <mdk@...> wrote:
        >
        > JSLINT is too strict !
        >
        >
        > var a = new Array(5);
        >
        > creates an empty array of length 5.
        > what the heck is wrong with that code ?
        >
        >
        > if i need an empty array then I'm forced to use
        >
        > var a = [,,,,];
        >
        > then what do i do, if i need to create a dynamic, variable length,
        > empty array ???

        new Array does not do what you think it does. Part of JSLint's mission
        is to help you discover where your reasonable expectations about
        JavaScript are incorrect. It is much harder to write correct programs
        if you do not understand what the language actually does. Use [].
      Your message has been successfully submitted and would be delivered to recipients shortly.