Skip to content

Instantly share code, notes, and snippets.

@brunosabot
Created March 30, 2022 17:52
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 brunosabot/1c90778188505dc22d9304ca647c6777 to your computer and use it in GitHub Desktop.
Save brunosabot/1c90778188505dc22d9304ca647c6777 to your computer and use it in GitHub Desktop.
const defaults = { debug: true };
const data = { ...defaults, output: "json" };
console.log(data); // {debug: true, output: "json"}
const data2 = { ...defaults, debug: false, output: "json" };
console.log(data2); // {debug: false, output: "json"}
const data3 = { debug: false, output: "json", ...defaults };
console.log(data3); // {debug: true, output: "json"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment