3 ms·
Around a decade ago, before frameworks ate the frontend, something close to this was on its way to becoming an informal standard in libraries, I suspect due to
by Izkata 5y ago
Around a decade ago, before frameworks ate the frontend, something close to this was on its way to becoming an informal standard in libraries, I suspect due to influence from jquery: Required arguments (such as an ID or DOM element) were the first positional arguments (typically only one, rarely a second), then the last argument was anything optional in an object (most often configuration).
For example:
createCarousel(dom_element, { delay: 10, circular: true});
var spinner = createSpinner(dom_element, { spokes: 5 });
spinner.remove();
And, if you were okay with all the defaults, the object was completely optional:
createSpinner(dom_element);
And a jquery example of the pattern:
jquery.post(url, { foo: 1, bar: 2 });