There's no need to use map/collect here - "each" should do just fine:
persons.each(function(p){ p.active = true }); or a plain loop if "each" is too slow: for (var i=persons.length; i--;) { persons[i].active = true; } P.S. Questions like this are better to be asked at http://groups.google.com/group/rubyonrails-spinoffs Best, kangax On Apr 29, 6:49 am, Xabi <[EMAIL PROTECTED]> wrote: > I've an array of Json objects > > var persons= [ {name:'peter', age:33}, {name:'john', age:27}, ..... ]; > > I want to extend every item with a new property with the same value, > by example, active:true > > [ {name:'peter', age:33, active:true}, {name:'john', age:27, > active:true}, ..... ] > > Now, I do > > persons=persons.collect(function(p) { > p.active=true; > return p; > > }) > > I think it does't the best method. Is there other more efficient > method? (the array is about 1000 length) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---