Options Object for JS functions

PHOTO EMBED

Wed Mar 20 2024 15:49:23 GMT+0000 (Coordinated Universal Time)

Saved by @dphillips #javascript

function test({ a = "foo", b = "bar", c = "baz" } = {}) {
  console.log(a + b + c);
}

test({c: "blub"});	// foobarblub
content_copyCOPY

https://stackoverflow.com/questions/9602449/a-javascript-design-pattern-for-options-with-default-values