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

Re: jslint alternative to (function(){...}).call({})

Expand Messages
  • douglascrockford
    ... I see no value in using this in that position. Try the following instead. It is slightly smaller and faster. (function (that) { // `that` is now {} }({}));
    Message 1 of 2 , Mar 26 11:29 AM
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "marcos.zanona" <marcos@...> wrote:

      > I would like to use the following statement so `this` is not DOMWindow anymore, although JSLint doesn't expect so see a `.`[dot] after (function(){...})
      > ---
      > (function () {
      > //`this` is now {} and now DOMWindow
      > }).call({});
      > ---
      > Is this a bad a approach, (why) ?
      > Also is there any good alternative to declare this?

      I see no value in using this in that position. Try the following instead. It is slightly smaller and faster.

      (function (that) {
      // `that` is now {}
      }({}));
    Your message has been successfully submitted and would be delivered to recipients shortly.