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

1294Re: [jslint] Re: function() -> function ()

Expand Messages
  • Marcel Duran
    May 2, 2010
    • 0 Attachment
      On Sun, May 2, 2010 at 2:56 PM, Cheney, Edward A SSG RES USAR USARC <
      austin.cheney@...> wrote:

      >
      >
      > That is not an anonymous function.
      >
      > The follow two are identical.
      >
      > var f = function () {
      > // body
      > };
      >
      > function f () {
      > // body
      > }
      >
      > They are not identical. This is a function declaration vs function
      expression. Consider the following:

      f();
      function f () {}

      This works because function declarations are hoisted to the top of the
      containing scope, changing this example to function expression:

      f();
      var f = function () {};

      This will cause an error (line 1), because the function isn't available in
      the variable f (line 2) which is not executed.

      By readability, I think Doug means:

      either
      var f = function (args) {};
      or
      function f (args) {}

      are clearly creating a function f

      where

      f('foobar');

      is clearly calling f.

      *note the space when creating f and no space when calling f

      Marcel


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