Total members 11894 |It is currently Fri Nov 22, 2024 6:27 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Applies the callback to the elements in given arrays.
function array_map( callback ) {
02. // Applies the callback to the elements in given arrays.
03. //
04. // version: 905.3122
05. // discuss at: http://phpjs.org/functions/array_map
06. // + original by: Andrea Giammarchi (http://webreflection.blogspot.com)
07. // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
08. // + improved by: Brett Zamir (http://brett-zamir.me)
09. // % note 1: Takes a function as an argument, not a function's name
10. // % note 2: If the callback is a string, it can only work if the function name is in the global context
11. // * example 1: array_map( function(a){return (a * a * a)}, [1, 2, 3, 4, 5] );
12. // * returns 1: [ 1, 8, 27, 64, 125 ]
13. var argc = arguments.length, argv = arguments;
14. var j = argv[1].length, i = 0, k = 1, m = 0;
15. var tmp = [], tmp_ar = [];
16.
17. while (i < j) {
18. while (k < argc){
19. tmp[m++] = argv[k++][i];
20. }
21.
22. m = 0;
23. k = 1;
24.
25. if( callback ){
26. if (typeof callback === 'string') {
27. callback = this.window[callback];
28. }
29. tmp_ar[i++] = callback.apply(null, tmp);
30. } else{
31. tmp_ar[i++] = tmp;
32. }
33.
34. tmp = [];
35. }
36.
37. return tmp_ar;
38.}




Author:
Newbie
User avatar Posts: 23
Have thanks: 1 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : JavaScript array_map
 JavaScript array_map     -  
 i need help in javascript     -  
 Javascript     -  
 When to use javascript?     -  
 using javascript     -  
 need help in javascript     -  
 need help with javascript     -  
 what is javascript ?     -  
 JavaScript     -  
 javascript help with BMI     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com