Last active
March 28, 2017 08:25
-
-
Save sscotth/0dc6ba0541b0547b718814c950f4bfcb to your computer and use it in GitHub Desktop.
Form serialization to 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
[...new FormData(document.querySelector('form'))].reduce((o, [name, value]) => ({ ...o, [name]: value }), {}) |
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
$('form').serializeArray().reduce((o, { name, value }) => ({ ...o, [name]: value }), {}) |
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
[...document.querySelector('form')].filter(el => el.name).reduce((o, { name, value }) => ({ ...o, [name]: value }), {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment