js prototype

来源:互联网 发布:合昏尚知时的下半句 编辑:程序博客网 时间:2024/06/08 20:06
/****/if(typeof Object.beget !== 'function'){    Object.beget = function(o){        var F = function(){};        F.prototype = o;        return new F();    }}/***/var foo = {    name : 'foo',    print: function(msg){        console.log(msg)    }}/***/foo.print('hello')/***/var bar = Object.beget(foo);bar.print('world');

0 0
原创粉丝点击