本文共 600 字,大约阅读时间需要 2 分钟。
var util=require('util');
this.sayHello=function(){
console.log('hello'+this.name);
Base.prototype.showName=function(){
util.inherits(Sub, Base);//在这里之后,sub就能继承到base得方法吗。
//objsub.sayHello();这里如果不注释掉就会报错
我们可以看到的是sub只继承了base在原型中声明的方法。同时这个方法并不能够被console.log()来打印出来。
http://nodejs.org/api/util.html
转载地址:http://nysmb.baihongyu.com/