Comments (3)
Person.prototype = Animal.prototype; // 人继承自动物
Person.prototype = new Animal(); // 人继承自动物
from node-interview-questions.
OSMeteor mentioned issue has been fixed in 0cd597e
NexZhu: New Animal()是实例化了。一般来说继承是类级别的,不需要实例化。
from node-interview-questions.
@jimuyouyou 原来这样写不是继承
这样Person.prototype与Animal.prototype是同一个对象,修改Person.prototype会影响父类Animal的prototype,而不是重载。
from node-interview-questions.
Related Issues (10)
- 一点点疑问 HOT 1
- nextTick() priority over setImmediate()
- 关于继承这里 HOT 1
- 还有一个比较常被问到的问题 HOT 1
- 继承 //构造器应用法 HOT 1
- setImmediate 和 nextTick 的优先级 HOT 2
- 关于捕获EventEmitter的错误事件 HOT 2
- 第一个关于执行顺序是错的 HOT 1
- 关于NodeJS全局变量的问题 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-interview-questions.