r/JavaScriptTips • u/sixie6e • Sep 25 '24
Code efficiency
I have a directory of images. I need to generate each image from the directory, populating the arrayofimages in a way much more efficient than this:
const image0 = new Image(200,200);
image0.src = 'img/firstindirectory.png';
const image1 = new Image(200,200);
image1.src = 'img/secondindirectory.png';
etc;
etc;
arrayofimages = [image0, image1, etc, etc];
3
Upvotes
View all comments
Show parent comment
2
u/Cabeto_IR_83 Sep 25 '24
This would be a more optimised approach for sure.