Skip to content

Instantly share code, notes, and snippets.

@dixon
Created November 16, 2017 18:19
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 dixon/4b31dc4245943d32766075fe95c418e4 to your computer and use it in GitHub Desktop.
Save dixon/4b31dc4245943d32766075fe95c418e4 to your computer and use it in GitHub Desktop.
jQuery.extend vs Object.assign when dealing with null and undefined
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