Skip to content

Instantly share code, notes, and snippets.

@namlet
Created March 26, 2015 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save namlet/c7558cdd99b429c373cd to your computer and use it in GitHub Desktop.
Save namlet/c7558cdd99b429c373cd to your computer and use it in GitHub Desktop.
Take jQuery.serializeArray() and map to custom Object
var serializedArray = [
{name: 'location', value:'Location one'},
{name: 'location', value:'Location two'}
]
// in practice
// var serializedArray = $(form).serializeArray();
var mappedObject = serializedArray.map(function(location){
return { location: location.value };
});
// mappedObject will now be [{location: "Location one"}, {location: "Location two"}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment