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

273Re: onevar

Expand Messages
  • ojacquem
    Oct 17, 2008
    • 0 Attachment
      Hello,

      --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...>
      wrote:
      >
      > I added a onevar option. It allows only one var statement per
      function.
      >
      Personally I don't think this practice should be recommended.
      It contradicts the related recommendation in the Code Conventions
      <http://javascript.crockford.com/code.html> page :-)

      It is preferred that each variable be given its own line and comment.
      (...)
      var currentEntry; // currently selected table entry

      var level; // indentation level
      var size; // size of table
      With a single var statement, all variables will typically be defined on
      the same line without comments, decreasing readability &
      maintainability.
      "Small code is more efficient in JavaScript"? This is the job of a
      minifier.

      Suggestion: check that all var statements are grouped at the beginning
      of the function. This will guarantee that scope problems are avoided,
      which was the purpose of introducing onevar, as I understand it.



      [Non-text portions of this message have been removed]
    • Show all 6 messages in this topic