这个图像加载功能有什么作用

What does this image onload function do?

本文关键字:什么 作用 功能 加载 图像      更新时间:2023-09-26

我遇到了这个片段,对我来说似乎很不寻常,谁能帮我解释一下它的目的是什么?提前谢谢。

image.onload = image.onerror = function () {
entry[name] =
image =
image.onload =
image.onerror = null;
delete entry[name];
};

您可以将其解释为:

当图像加载出现错误时,请移除与 图像并删除entry[name]

您可以"链接"属性,以便它们都具有相同的值:

this.name = 'bob';
this.age = '21';
this.name = this.age = null; /* <<---Both properties are now null*/