Hi,
Applies the callback to the elements in given arrays.
function array_map( callback ) {
02. // Applies the callback to the elements in given arrays.
0*. //
04. // version: *05.**22
05. // discuss at: [url]http://phpjs.org/functions/array_map[/url]
06. // + original by: Andrea Giammarchi ([url]http://webreflection.blogspot.com[/url])
07. // + improved by: Kevin van Zonneveld ([url]http://kevin.vanzonneveld.net[/url])
08. // + improved by: Brett Zamir ([url]http://brett-zamir.me[/url])
0*. // % note *: Takes a function as an argument, not a function's name
*0. // % note 2: If the callback is a string, it can only work if the function name is in the global context
**. // * example *: array_map( function(a){return (a * a * a)}, [*, 2, *, 4, 5] );
*2. // * returns *: [ *, 8, 27, 64, *25 ]
**. var argc = arguments.length, argv = arguments;
*4. var j = argv[*].length, i = 0, k = *, m = 0;
*5. var tmp = [], tmp_ar = [];
*6.
*7. while (i < j) {
*8. while (k < argc){
**. tmp[m++] = argv[k++][i];
20. }
2*.
22. m = 0;
2*. k = *;
24.
25. if( callback ){
26. if (typeof callback === 'string') {
27. callback = this.window[callback];
28. }
2*. tmp_ar[i++] = callback.apply(null, tmp);
*0. } else{
**. tmp_ar[i++] = tmp;
*2. }
**.
*4. tmp = [];
*5. }
*6.
*7. return tmp_ar;
*8.}