[英]How can I understand what this JavaScript code means?
What does this JavaScript code mean?这段 JavaScript 代码是什么意思?
img.file = file;
const reader = new FileReader();
reader.onload = (function(aImg) {
return function(e) {
aImg.src = e.target.result;
};
})(img);
Specifically this具体来说这个
reader.onload = (function(){...})()
This is an Immediately Invoked Function Expression (IIFE)这是一个立即调用函数表达式 (IIFE)
https://developer.mozilla.org/en-US/docs/Glossary/IIFE would be helpful in your case. https://developer.mozilla.org/en-US/docs/Glossary/IIFE会对您的情况有所帮助。
It creates a function and immediately calls it.它创建一个函数并立即调用它。 You can find some use cases in the link above
您可以在上面的链接中找到一些用例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.