On Thu, Oct 29, 2009 at 4: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:

I think that would be quite different from the way map currently
works, which does not modify the array passed in but returns a new
array whose values are the results of applying the callback function
to each successive value of the original one.

> var obj = { a: function() { alert(1) }, b: function() { alert(2) } };
> $.map( obj, function( value, key ) {
>    return function() {
>        // Call old function
>        value();
>
>        // Do something else;
>    };
> })

I'm not making much sense out of that.  Are you assuming that every
property of the "obj" parameter is a function?  Can you give some
context and a more real-world example?  This does not sound hard to
write, but I'm not seeing the benefits.


> 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 )

I don't know what scoping issue you're talking about, but I think that
the only real way to enumerate the properties of an object involves
for-in.

  -- Scott

--

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