Jennifer Massey
Jennifer Massey

Reputation: 173

What does this image onload function do?

I came across this snippet, and it seems quite unconventional to me, can anyone help me explain what's the purpose of it? Thanks in advance.

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

Upvotes: 1

Views: 65

Answers (1)

KJ Price
KJ Price

Reputation: 5964

You can interpret that as:

when image loads or has an error, remove any other events tied to the image and also delete entry[name].

You can "chain" properties so that they all have the same value:

this.name = 'bob';
this.age = '21';

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

Upvotes: 1

Related Questions