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
1 Answer
Reset to default 4It'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
版权声明:本文标题:javascript - Could you tell me what is function(el)? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744368000a2602877.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论