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

1291Re: function() -> function ()

Expand Messages
  • Douglas Crockford
    May 1 12:18 PM
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, Rob Richardson <erobrich@...> wrote:
      >
      > JSLint reports that anonymous functions such as this:
      >
      > var f = function(args) {
      > // body
      > }
      >
      > would be better like this:
      >
      > var f = function (args) {
      > // body
      > }
      >
      > Why is the space between 'function' and '(' preferable?

      It is for readability. It makes it clearer that you are creating a function and not calling a function.

      Also, you forgot the semicolon.
    • Show all 19 messages in this topic