On 17 September 2010 13:26, Jarkko Laine <jar...@jlaine.net> wrote:
>
> On 17.9.2010, at 15.03, Richard Quadling wrote:
>
>> Hi.
>>
>> How do I do something like this (just an example) ...
>>
>> [1,2,3].each(function(val){return val * val;});
>>
>> such that the result is ...
>>
>> [1,4,9]
>
> [1,2,3].map(function(i){ return i * i }); // 
> http://api.prototypejs.org/language/enumerable/prototype/collect/
>
> Note that invoke is a shorthand for map except that it calls a method for 
> each of the items:
>
> ['hello', 'world'].invoke('toUpperCase'); // 
> http://api.prototypejs.org/language/enumerable/prototype/invoke/
> // -> ['HELLO', 'WORLD']
>
> Cheers,
> //jarkko

.map()

ARGHH!! Wood 4 trees....



-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to