A widely used utility when writing jQuery plugins or modern webapps is the exdend function. This method allows you to copy the keys of one object into another.

It is also known as assign, and both jQuery and Underscore provide it out of the box. If you want to write your own implementation, this is a starting point (without deep copy):

function extend (dest, source) {
  for (var prop in source) {
      if (source.hasOwnProperty(prop)) {
          dest[prop] = source[prop];
      }
  }
    return dest;
}

An example of use is within a module, where you can define some default values and then override them at runtime, per instance:

// Example of module 
var MyModule = function (options) {
  var settings = {
      a: 0,
      b: 0
  };
  extend(settings, options || {})
  //...
};

var foo = new MyModule({ a: 1 });
var baz = new MyModule();
// now foo instance has settings.a = 1
// while baz settings.a is still 0

If you are looking for more complex extend functions check out jQuery, Underscore or Lo-Dash source code.