//寄生式继承是原型继承密切相关的一种思路,。寄生式继承的思路与寄生构造函数和工厂模式类似,即创建一个仅用于封装继承过程
//的函数,该函数在内部以某种方式来增强对象,
function object(o){
function F(){}
F.prototype = o;
F.name = "shalio";
}
function createAnother(original){
var clones = object(original);
clones.sayHi = function(){
console.log("Hi");
};
return clones;
}
var person ={name:"shali",
friends:["1","s"]};
var anotherperson = createAnother(person);
anotherperson.sayHi();
原文:http://www.cnblogs.com/lovefan/p/3884241.html