Home / Advanced JavaScript Tutorial / Creating Robusts Functions |
CodingForums Jump to...
- CSS Drive
- PHP Resources - Hotels & Vacations - Bad credit cards - JavaScript Menus |
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(){ //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() A simple demonstration of the above in action would be: <head> -Tutorial introduction |
. http://javascriptkit.com |