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

Re: Warning on unnecessary use of call/apply?

Expand Messages
  • douglascrockford
    ... I continue to be amazed at the terrible code that people want to write. ... Please try it now. And thank you for thoughtfully providing the cases.
    Message 1 of 3 , Sep 18, 2012
    • 0 Attachment
      --- In jslint_com@yahoogroups.com, "chrisprice0101010" <price.c@...> wrote:

      > Whilst reviewing some code, I spotted an unnecessary use of call and it stood out to me as a good candidate for a warning.


      I continue to be amazed at the terrible code that people want to write.


      > The following code demonstrates the situations that I believe should trigger the warning, they all suggest to me that the author has not fully understood when it is appropriate to use call/apply -
      >
      > (function () {
      > "use strict";
      > var a = {
      > b: function () {}
      > },
      > c = 1;
      >
      > a.b.apply(a, [c]); // WARN
      > a.b.apply(a); // WARN
      > a.b.call(a, c); // WARN
      > a.b.call(a); // WARN
      > }());


      Please try it now. And thank you for thoughtfully providing the cases.
    • Chris Price
      Works great, thanks! ... [Non-text portions of this message have been removed]
      Message 2 of 3 , Sep 18, 2012
      • 0 Attachment
        Works great, thanks!

        On Tue, Sep 18, 2012 at 3:21 PM, douglascrockford <douglas@...>wrote:

        > **
        >
        >
        > --- In jslint_com@yahoogroups.com, "chrisprice0101010" <price.c@...>
        > wrote:
        >
        > > Whilst reviewing some code, I spotted an unnecessary use of call and it
        > stood out to me as a good candidate for a warning.
        >
        > I continue to be amazed at the terrible code that people want to write.
        >
        >
        > > The following code demonstrates the situations that I believe should
        > trigger the warning, they all suggest to me that the author has not fully
        > understood when it is appropriate to use call/apply -
        > >
        > > (function () {
        > > "use strict";
        > > var a = {
        > > b: function () {}
        > > },
        > > c = 1;
        > >
        > > a.b.apply(a, [c]); // WARN
        > > a.b.apply(a); // WARN
        > > a.b.call(a, c); // WARN
        > > a.b.call(a); // WARN
        > > }());
        >
        > Please try it now. And thank you for thoughtfully providing the cases.
        >
        >
        >


        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.