对象扩展

// 定义一个app对象,并对app对象进行扩展
var app = {
  name: "tom"
};

// 扩展方法
function extend(destination, source) {
  for (var property in source) {
    destination[property] = source[property];
  }

  return destination;
}

// 扩展实例
extend(app, {
  city: "hangzhou"
});

console.log(app.city); // "hangzhou"