NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
``` let util = require('util'); function A(){ this.name = 'h123'; } A.attr= 'a'; A.prototype.method = function(){ console.log('methodA'); }; function B(){ A.call(this); //能继承A产生对象的属性 } util.inherits(B,A); //继承A产生对象的方法 //B.prototype.__proto__ = A.prototype console.log(B.attr); //undefined let b = new B(); b.method(); //methodA console.log(B.prototype.constructor); //仍然指向B构造函数 console.log(b.name); //h123 ```