Skip to content

Instantly share code, notes, and snippets.

@thewisenerd
Created March 14, 2024 16:37
Show Gist options
  • Save thewisenerd/c805d7d8e3fa1ac23f9925001757bb3d to your computer and use it in GitHub Desktop.
Save thewisenerd/c805d7d8e3fa1ac23f9925001757bb3d to your computer and use it in GitHub Desktop.
const defaults = {
'a': 1
};
const foo = (flag = false) => {
let headers: any = defaults;
if (flag) {
headers['b'] = 2;
}
return headers;
}
console.log(foo());
console.log(foo(true));
console.log(foo());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment