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

799Re: Anonymous callback in prototype

Expand Messages
  • cdcmicro
    Aug 10, 2009
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
      >
      > --- In jslint_com@yahoogroups.com, "cdcmicro" <cdcmicro@> wrote:
      > > I'm not sure this is a problem, or if I'm just reading the report wrong. When creating an anonymous function (a callback) as an arg to a function:
      > >
      > > /*global myparams, myfunc */
      > > myfunc(myparams, function (cbdata) {
      > >
      > > });
      > >
      > > function myfunc (params, callback) {
      > > return callback();
      > > }
      > >
      > > The report indicates:
      > >
      > > 2-4 "myparams"(cbdata)
      > >
      > > 6-8 myfunc(params, callback)
      > >
      > > as if myparams is the function name, but not really.
      >
      > JSLint tries to guess a name for anonymous functions.
      > Guessed names are wrapped in quotes.
      >
      > You should only use /*global */ for names that are defined
      > outside of the file. So,
      >
      > /*global myparams */
      >
      > function myfunc(params, callback) {
      > return callback();
      > }
      >
      > myfunc(myparams, function (cbdata) {
      >
      > });
      >

      Got it. I understand now about the quoted, "guessed" name. Thanks for the quick clarification.

      -Clark
    • Show all 3 messages in this topic