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

Re: possible erroneous warning due to multi-line layout

Expand Messages
  • ossayu
    The following also works: (function () { ```` use strict ; ````var processTheForm; ````processTheForm = function () { ````````var resultObjHash, ````````````//
    Message 1 of 7 , May 13, 2011
    • 0 Attachment
      The following also works:

      (function () {
      ````'use strict';
      ````var processTheForm;
      ````processTheForm = function () {
      ````````var resultObjHash,
      ````````````// functions
      ````````````createElemHandler,
      ````````````createResultObj;
      ````````createElemHandler = function () {
      ````````};
      ````````createResultObj = function () {
      ````````};
      ````````resultObjHash = {};
      ````};
      }());

      That said, why is there no warning if there is a second variable declared on the line with the var keyword, as in:

      The following also works:

      (function () {
      ````'use strict';
      ````var processTheForm;
      ````processTheForm = function () {
      ````````var resultObjHash, anotherVar,
      ````````````// functions
      ````````````createElemHandler, createResultObj;
      ````````createElemHandler = function () {
      ````````};
      ````````createResultObj = function () {
      ````````};
      ````````resultObjHash = {};
      ````};
      }());
    • Zhami
      ... Two reasons: 1) because I don t do the former... there were a number of names declared as variables. 2) I don t like to clutter the list of variable
      Message 2 of 7 , May 13, 2011
      • 0 Attachment
        --- In jslint_com@yahoogroups.com, "Cheney, Edward A SSG RES USAR USARC" <austin.cheney@...> wrote:

        > I do have one complaint/question. Why would you do this:
        >
        > var processTheForm;
        > processTheForm = function () {...
        >
        > Instead you could do this:
        > var processTheForm = function () {...
        >

        Two reasons:

        1) because I don't do the former... there were a number of names declared as variables.

        2) I don't like to clutter the list of variable declarations with assignments. While the interpreter allows it, I prefer to keep very distinct variable name declarations, and assignment of values.
      • Zhami
        I have been having an off-list conversation with someone who has helped me understand that my original problem statement may be opaque. The essence is this:
        Message 3 of 7 , May 13, 2011
        • 0 Attachment
          I have been having an off-list conversation with someone who has helped me understand that my original problem statement may be opaque. The essence is this:

          The following is okay:

          var a, b,
          c, d;


          The following generates a warning about the position of d:

          var a,
          c, d;
        Your message has been successfully submitted and would be delivered to recipients shortly.