admin管理员组

文章数量:1402846

I have some code:

hideLoadMask : function(response,config){
    //Once the response is processed for a particular request it will be removed from the processing array
    this.loadMaskRequestQueue =
            this.loadMaskRequestQueue.filter(function (el) {
                return el.requestID !== response.requestID;
        });
}

Here in el contains the data like:

loadingText: "Loading...Please wait."
requestID: 1

When I call hideLoadMask(), I pass response="Loading...Please wait."

Could you tell me what is function(el), how my response parameter's value became as a field to el, what is requestID.

Please clarify my doubts.

I have some code:

hideLoadMask : function(response,config){
    //Once the response is processed for a particular request it will be removed from the processing array
    this.loadMaskRequestQueue =
            this.loadMaskRequestQueue.filter(function (el) {
                return el.requestID !== response.requestID;
        });
}

Here in el contains the data like:

loadingText: "Loading...Please wait."
requestID: 1

When I call hideLoadMask(), I pass response="Loading...Please wait."

Could you tell me what is function(el), how my response parameter's value became as a field to el, what is requestID.

Please clarify my doubts.

Share Improve this question edited Apr 28, 2020 at 8:09 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Mar 10, 2016 at 6:07 NageswaraRao .KNageswaraRao .K 531 gold badge1 silver badge8 bronze badges 1
  • 1 developer.mozilla/en-US/docs/Web/JavaScript/Reference/… – Bergi Commented Mar 10, 2016 at 6:12
Add a ment  | 

1 Answer 1

Reset to default 4

It's an inline anonymous function definition that serves as a callback to the .filter() method.

The .filter() method takes a callback that it calls to carry out it's operation. You can either define a named function elsewhere and then pass that function's name or you can define the callback function inline with this type of syntax.

The el in the function(el) signifies that the .filter() method will call the callback with at least argument (the array element currently being filtered) and this is the argument that the callback wishes to use. If you check the documentation for .filter() here, you will see that it actually passes three arguments to the callback, but this particular callback only cares to use the first argument so that's the only one it bothers to declare.

本文标签: javascriptCould you tell me what is function(el)Stack Overflow