Util is a core module of Nodejs, used to provide a collection of commonly used functions
1.util.inherits (Implementing object prototype inheritance)
Summary: JS inheritance is based on the prototype, and itself does not inherit the language characteristics, simply by copying the way to implement the original object.
First, in the NODEJS environment to introduce the Util module
Const UTIL = require (' util ');
Ii. inheritance
function Sayname () {
this.name = ' Joink ';
This.say = function () {Console.log (this.name)};
}
function SetName () {
this.name = ' Lebron ';
}
Now you want the function SetName to inherit sayname methods and properties.
Util.inherits (Setname,sayname); SetName Inheritance Sayname
At this point, the new one sayname, and executes the inside properties, methods, will find that nothing changes.
But, new one setname try. It will be found that this object has all the methods of Sayname, and name has been changed. Here is an example
Nodejs's Util tool