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

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

Expand Messages
  • Rob Richardson
    May 3, 2010
      I've typically used the keyword 'function' to denote that I'm creating a function. In quick testing, I find no way to call a function with the keyword 'function' present ... short of creating a Function.doit = function () {... which just seems silly, and no way to create a function called 'function' without similar pain. Is there a way to invoke a function with the 'function' keyword present? What's an (albeit likely horrid) example where one could get confused between creation and invocation due to similar syntax?


      From: Douglas Crockford <douglas@...>
      To: jslint_com@yahoogroups.com
      Sent: Sat, May 1, 2010 12:18:24 PM
      Subject: [jslint] Re: function() -> function ()

      --- In jslint_com@yahoogro ups.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.

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