原型继承

var a = {
     name: '小明'
}

var b = cloneObj(a);

alert(b.name);     //'小明'

function cloneObj(obj){
    var F = function(){};
    F.prototype = obj;
    return new F();
}

 

posted @ 2018-04-13 15:03  阿弥陀佛么么哒!  阅读(152)  评论(0编辑  收藏  举报