Util.inherits
Util.inherits (constructor, Superconstructor) is a function that implements prototype inheritance between objects.
The object-oriented nature of JavaScript is prototype-based and differs from common class-based ones. JavaScript does not provide language-level attributes for object inheritance, but is implemented through prototype replication.
varUtil = require (' util '));functionBase () { This. Name = ' base '; This. Base = 1991; This. SayHello =function() {Console.log (' Hello ' + This. Name); };} Base.prototype.showName=function() {Console.log ( This. name);};functionSub () { This. Name = ' Sub ';}
Util.inherits (Sub, Base);
varObjbase =Newbase (); Objbase.showname (); Objbase.sayhello (); Console.log (objbase);
varObjsub =NewSub (); Objsub.showname ();//Objsub.sayhello (); no accessConsole.log (objsub);
Util.inspect
Util.inspect (Object,[showhidden],[depth],[colors]) is a method that converts any object to a string, typically for debugging and error output. It accepts at least one parameter, object, which is to be converted.
ShowHidden is an optional parameter, and if the value is true, more hidden information will be output.
Depth represents the maximum number of recursive layers, and if the objects are complex, you can specify the number of layers to control how much output information is.
If you do not specify depth, the default is 2 levels, which is specified as null to completely traverse the object with an unlimited number of recursive layers.
If the color value is true, the output format will be encoded in ANSI color, typically used to display a more beautiful effect on the terminal.
In particular, Util.inspect does not simply convert an object to a string, even if the object defines the ToString method and does not invoke the
Util.isarray () Util.isregexp () util.isdate () Util.iserror () Util.format () util. Debug ()