var util=require('util'); function Base(){ this.name='base'; this.base=2012; this.sayHello=function(){ console.log('hello '+this.name+' this year is '+this.base); }; } Base.prototype.showName=function(){ console.log(this.name); } function Sub(){ this.name='sub'; } util.inherits(Sub,Base); var objBase=new Base(); objBase.showName(); objBase.sayHello(); console.log(objBase); var objSub=new Sub(); objSub.showName(); //objSub.sayHello();//error console.log(objSub);
var util=require('util'); function Person(){ this.name='marico'; this.toString=function(){ return this.name; } } var obj=new Person(); console.log(util.inspect(obj)); console.log(util.inspect(obj,true,2,true));