Created
March 26, 2015 18:35
-
-
Save namlet/c7558cdd99b429c373cd to your computer and use it in GitHub Desktop.
Take jQuery.serializeArray() and map to custom Object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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