var input=[ { name: 'John' }, { name: 'Sam' }, { name: 'Marry' } ]; var output=[]; $.each(input, function (index, value){ output.push(value.name); });
Using for (...), as shown in several of the answers above, works fine, but you also run the risk of adding members you don't want, or getting confused by some errors when trying to grab a property name from a member that does not have this property. See: Why is using βfor ... inβ with array iteration a bad idea?
source share