Since JavaScript has been doing for only a month, I have not really learned the details yet. Need clarification on how the code works. Namely - what happens in each line of code:
function preloadImages() { if (typeof arguments[arguments.length - 1] == 'function') { var callback = arguments[arguments.length - 1]; } else { var callback = false; } if (typeof arguments[0] == 'object') { var images = arguments[0]; var n = images.length; } else { var images = arguments; var n = images.length - 1; } var not_loaded = n; for (var i = 0; i < n; i++) { jQuery(new Image()).attr('src', images[i]).load(function() { if (--not_loaded < 1 && typeof callback == 'function') { callback(); } }); } }