Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
let defaults = {},
overrides = {};
function foo(bar, options) {
// YUI
options = Y.merge(defaults, options, overrides);
// Underscore
options = _.extend({}, defaults, options, overrides);
// ES6
options = [defaults, options, overrides].reduce(Object.assign, {});
// ES6 YUI `Object.assign()` sugar.
Y.assign = function (target, ...sources) {
return sources.reduce(Object.assign, target);
// ES6 back-compat `Y.merge()`.
Y.merge = function (...sources) {
return Y.assign({}, ...sources);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.