Lets now provide some examples using "robust" functions.

Example 1

The first is a simple summation notation example, where a function adds up all of the numbers that get passed into it:

function summation(){
for (i=0;i<summation.arguments.length;i++){

//call the function

Example 2- Robust Preload Image Script

By default, whenever we wish to preload images (for use with rollover effects, for example), we have to go through the tedious steps of first creating a new image object for each image, then, for each image object, specify the path to the image itself. Using the rebust function concept, we can create a function whereby the webmaster simply has to enter the names of the images he/she wishes to preload, and they automatically get preloaded:

var myimages=new Array()
function preloadimages(){
	for (i=0;i<preloadimages.arguments.length;i++){
		myimages[i]=new Image()

A simple demonstration of the above in action would be:

preloadimages("firstimage.gif", "secondimage.gif", "thirdimage.gif")