0

This method syntax seems to be little strange.

Here is the method declaration. Some normal javascript method implementation.

sendHttpRequest: function (aUri, aUploadData, aContentType, aExisting, aSetupChannelFunc, aFailureFunc, aUseStreamLoader = true) {
    //method implementation
}

This is the actual usage. There what does mean by using ()=>{//some statements} as a parameter?

function someFunction(){
    this.calendar.sendHttpRequest(requestUri, queryXml, MIME_TEXT_XML, null, (channel) => {
       //some statements
        return this;
    }, () => {
        if (this.setA && this.setB) {
       //some statements
        }
    }, false);

//someFunction's statements

}
underscore
  • 5,787
  • 4
  • 30
  • 72
Marlio
  • 170
  • 3
  • 17
  • possible duplicate of [Immediate function using JavaScript ES6 arrow functions](http://stackoverflow.com/questions/22138550/immediate-function-using-javascript-es6-arrow-functions) – thefourtheye May 04 '14 at 13:10
  • Also, [this question](http://stackoverflow.com/questions/22939130/when-should-i-use-arrow-functions-in-ecmascript-6) will be an eye-opener. – thefourtheye May 04 '14 at 13:10
  • 1
    MDN Documentation for [Arrow functions](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/arrow_functions) – thefourtheye May 04 '14 at 13:11
  • can you elaborate the situation of this ? – underscore May 04 '14 at 13:12
  • Where did you find that code (link please)? Are you sure that it's JS, not something like Coffeescript? – Bergi May 04 '14 at 13:22
  • 1
    For someone who like to contribute, http://mxr.mozilla.org/comm-central/source/calendar/providers/caldav/calDavCalendar.js#668 this is the method declaration.. http://mxr.mozilla.org/comm-central/source/calendar/base/modules/calProviderUtils.jsm#69 – Marlio May 04 '14 at 14:38
  • @Bergi yes it's javascript. – Marlio May 04 '14 at 14:39
  • @thefourtheye Thank you.! That's what exactly it is! – Marlio May 04 '14 at 14:40
  • @Bergi Its a ES6 feature :) – thefourtheye May 04 '14 at 14:41
  • @thefourtheye: Yeah, I know, but it's also a coffeescript feature :) Since OP hadn't mentioned where he came across this, I was not sure. In this case it seems to be FF-specific (though of course ES6-based) – Bergi May 04 '14 at 15:57
  • @Bergi Oh, I don't know CoffeeScript. So, I was surprised to see that comment from you :-) – thefourtheye May 04 '14 at 15:59

0 Answers0