javascript – Why is the generated img object "img.style.display =" none'; "after" img.onload "?

Question: Question:

In the linked "color picker", "img.style.display ='none';" is displayed after "img.onload". What does that mean?
・ The behavior was the same even if I commented it out.

Even if "display ='none';", the image is not hidden …
-Is it unnecessary to use img because I drew it on canvas?
-Since the img object was just created (because it is not included in the DOM), I don't think it is necessary to hide it …
-Hide instead of delete? ??

var ctx = canvas.getContext('2d');
img.onload = function() {
  ctx.drawImage(img, 0, 0);
  img.style.display = 'none';
};

mdn

Answer: Answer:

As the questioner said, I can't think of a reason, and I don't think it makes sense.

Scroll to Top