Total members 9951 | Gratitudes |It is currently Sat Feb 11, 2012 10:09 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Question
 Question subject: JavaScript array_map
PostPosted: Mon Aug 17, 2009 1:13 pm 
Offline
Newbie
User avatar

Joined: Fri Jun 26, 2009 5:50 am
Posts: 23
Has thanked: 0 time
Have thanks: 1 time

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.}

_________________
Thanks & regards
Lokananth
[url "http://www.mioot.com"]Live Chat Software[/url] By miOOt


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  


 Similar topics
 Topic title   Forum   Author   Comments 
 Need to Display Content using JavaScript in HTML page  Scripting Language  stankov  0
 getting gst, pst total to diplay in my javascript form  Scripting Language  Anonymous  0
 need help with javascript  Scripting Language  triscuit  0
 Javascript select menu validation issue  Scripting Language  Anonymous  0
 validate age entered as selection box in javascript  JavaScript examples  msi_333  0

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 2 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team