Today is a good gas, recently hung up some interview after a slight loss of mood.
God Horse is a cloud, to always do the world second.
No more, you ask me why the mentality has changed. -------are feelings,.
Well, I'm studying node recently.
People ask, you have this level of node ...
hahaha, so sad ....
Don't mention it.
God Horse modular God horse is not much to say, on a module.export and export differences, the latter object of the property belongs to the former, inverse proposition is not established.
and Util.inherits (A, B) This API note that A will only inherit the prototype method of B, not the prototype will inherit. It's not that the data in the prototype is shared, so it's estimated that this function creates a reference.
Well, to get to the point, "node. JS Development Combat Detail" This book is still very open to the novice, but after reading the second chapter, I feel like something is wrong.
The book mentions the Observer pattern, as if there is no special section to say, an example in the after-school combat ... Uh... There is really no observer in the catalogue ... Alas, this is all a small problem.
This static class still finds minor problems:
Here is a base class. Person.js file name.
/* defining the person base class */ module.exports=function() { this. name= ' person '; this. sleep=function() { console.log (' person sleep '); } this. eat=function() { console.log (' person eat ');} }
Then here is a derived class, Student.js filename
varUtil=require (' Util ');varPerson=require ('./person '));functionStudent () {Person.call ( This); Util.inherits (Student,person); This. study=function() {Console.log (' Study person '); }}varperson=NewStudent ();//In fact, the main point is here, the book is so written on the Var person=new person (); Well, obviously not, and if so, what's the student () method? exports.study=person.study;exports.eat=Person.eat;exports.sleep=person.sleep;
Then run the file app.js.
var student =require ('./student '); Student.study (); Student.eat (); Student.sleep ();
Uh.. You're done so soon? Well, see another question again. This update below. Make a mark: 2015-4-13-16-46 (Lost time, relentlessly. Alas
Static class objects in node. js Inheritance (some bug fixes in the "node. JS Development Walkthrough" book)