Created
November 16, 2017 18:19
-
-
Save dixon/4b31dc4245943d32766075fe95c418e4 to your computer and use it in GitHub Desktop.
jQuery.extend vs Object.assign when dealing with null and undefined
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 o = { test: 'asdfasdf' } | |
> undefined | |
$.extend({}, o, { test: null }) | |
> {test: null} | |
$.extend({}, o, { test: undefined }) | |
> {test: "asdfasdf"} | |
Object.assign({}, o, { test: null }) | |
> {test: null} | |
Object.assign({}, o, { test: undefined }) | |
> {test: undefined} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment