Skip to content

Instantly share code, notes, and snippets.

@kitz99
Last active July 5, 2018 07:30
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 kitz99/f7257af12edf14f693edff1fb806ae71 to your computer and use it in GitHub Desktop.
Save kitz99/f7257af12edf14f693edff1fb806ae71 to your computer and use it in GitHub Desktop.
function withoutDestruct(config) {
var opt1 = config.opt1 !== undefined ? config.opt1 : "foo";
var opt2 = config.opt2 !== undefined ? config.opt2 : "foobar";
var opt4 = config.opt3 !== undefined ? config.opt3 : "baz";
console.log(opt1, opt2, opt3);
}
withoutDestruct({opt1: "hello ", opt2: "world", opt3: "!"}); // > "hello world!"
function withDestruct({ opt1 = "foo", opt2 = "foobar", opt3 = "baz"}) {
console.log(opt1, opt2, opt3)
}
withDestruct({ opt1: "hello ", opt2: "world", opt3: "!" }); // > "hello world!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment