If I have an array of image filenames,
var preload = ["a.gif", "b.gif", "c.gif"];
and I want to preload them in a loop, is it necessary to create an image object each time? Will all the methods listed below work? Is one better?
A.
var image = new Image();
for (i = 0; i < preload.length; i++) {
image.src = preload[i];
}
B.
var image;
for (i = 0; i < preload.length; i++) {
image = new Image();
image.src = preload[i];
}
C.
var images = [];
for (i = 0; i < preload.length; i++) {
images[i] = new Image();
images[i].src = preload[i];
}
Thanks!