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

Re: Function chaining and whitespace issue

Expand Messages
  • douglascrockford
    Or you can break compactly before ) . var someFunction = function () { use strict ; }; someFunction()(someFunction)(someFunction)(someFunction
    Message 1 of 5 , Feb 2, 2012
    • 0 Attachment
      Or you can break compactly before ')'.

      var someFunction = function () { 'use strict'; };
      someFunction()(someFunction)(someFunction)(someFunction
      )(someFunction)(someFunction);

      The thing you can't do is break between ')' and '(' because of the semicolon insertion hazard.
    • mariuszn3
      Thanks, somehow I didn t think about writing it that way, it indeed makes sense.
      Message 2 of 5 , Feb 2, 2012
      • 0 Attachment
        Thanks, somehow I didn't think about writing it that way, it indeed makes sense.


        --- In jslint_com@yahoogroups.com, "douglascrockford" <douglas@...> wrote:
        >
        > Or you can break compactly before ')'.
        >
        > var someFunction = function () { 'use strict'; };
        > someFunction()(someFunction)(someFunction)(someFunction
        > )(someFunction)(someFunction);
        >
        > The thing you can't do is break between ')' and '(' because of the semicolon insertion hazard.
        >
      • douglascrockford
        Or you can wrap the whole thing in parens: var someFunction = function () { use strict ; }; (someFunction() (someFunction) (someFunction) (someFunction)
        Message 3 of 5 , Feb 10, 2012
        • 0 Attachment
          Or you can wrap the whole thing in parens:

          var someFunction = function () { 'use strict'; };
          (someFunction()
          (someFunction)
          (someFunction)
          (someFunction)
          (someFunction)
          (someFunction));
        Your message has been successfully submitted and would be delivered to recipients shortly.