Combining text in an array in JavaScript My JS looks like this:

preLoadImages("/media/img/elements/frontpage/1.jpg","/media/img/elements/frontpage/2.jpg","/media/img/elements/frontpage/3.jpg","/media/img/elements/frontpage/4.jpg","/media/img/elements/frontpage/5.jpg","/media/img/elements/frontpage/6.jpg","/media/img/elements/frontpage/7.jpg","/media/img/elements/frontpage/8.jpg","/media/img/elements/frontpage/9.jpg","/media/img/elements/frontpage/10.jpg");


What would be a better way to do this?

var directory = "/media/img/elements/frontpage/"

preLoadImages(directory+"1.jpg",directory+"2.jpg",directory+"3.jpg",directory+"4.jpg",directory+"5.jpg",directory+"6.jpg",directory+"7.jpg",directory+"8.jpg",directory+"9.jpg",directory+"10.jpg");


Doesn't seem much better. There must be a zip/map/join type thing I can use here?
perhaps you can try apply(), then you can pass in the image paths as an array:

preLoadIamges.apply(this, absoluteFileNames)


then you can build you array in a the way you like, perhaps looking at this unobtrusive implementation of Array.map:

var directory = "/media/img/elements/frontpage/"
var fileNames = ["1.jpg","...","9.jpg"]; 
var absoluteFileNames = fileNames.map(function (value) { 
    return directory + value; 
});