But making map() functions work on hashes makes sense, so why rule
them out?

On Oct 30, 10:08 am, Robert Katić <robert.ka...@gmail.com> wrote:
> Generally map() functions work on sequences (values indexed by
> numbers).
>
> On Oct 30, 1:08 am, gMinuses <gminu...@gmail.com> wrote:
>
> > From it's name, I think It should be general, and should be working on
> > all kinds of arrays. The object I'm talking about here is actually a
> > hash, which is a kind of array, and I figure it'd be appropriate to
> > let $.map() also work for it.
>
> > On Oct 30, 3:20 am, Robert Katić <robert.ka...@gmail.com> wrote:
>
> > > Be warned that $.map() is designed to work on a sequence of DOM
> > > elements. Although it would work with other values too, callback
> > > results are not handled as you probably expect: null and undefined
> > > values are discarded and arrays are merged to the final array.
>
> > > In your case an classic for(key in obj) would be more appropriate, I
> > > think.
>
> > > On Oct 29, 9:56 am, gMinuses <gminu...@gmail.com> wrote:
>
> > > > I'm not sure if it's necessary, but I feel It'd be nice that we can
> > > > pass an object to $.map(), so that jquery will iterate over it's
> > > > properties and modifies values by calling the callback function:
>
> > > > var obj = { a: function() { alert(1) }, b: function() { alert(2) } };
> > > > $.map( obj, function( value, key ) {
> > > >     return function() {
> > > >         // Call old function
> > > >         value();
>
> > > >         // Do something else;
> > > >     };
>
> > > > })
>
> > > > If the idea is redundant because of my lack of knowledge, please let
> > > > me know how to do it natively, thanks. ( If you are going to suggest "
> > > > for( in ) ", I think it doesn't have the benefit of scoping )

--

You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to