prototype和__proto__
2015-10-09 19:03
281 查看
function Person(name){ this.name = name; } Person.prototype.hi = function(){ console.log("hi", this.name); } function Student(name,age){ Person.call(this, name, age); this.age = age; } Student.prototype = Object.create(Person.prototype); Student.prototype.hi = function(){ console.log("student"); } var obj = new Student("hqq", 22); console.log(obj);
看到此图就知道JS的原型链了吧。
最后都会指向Object,然后Object.prototype.__proto__ 是 null
每个函数都有一个prototype属性:
每个对象都有一个__proto__指向原型链:
相关文章推荐
- 错误记录--server tomcat v8.0 server at localhost failed to start
- hdu2255 KM模板
- 程序开发中的oracle必备知识
- 面向对象的多态性
- Naive Bayes笔记
- Codeforces Round #6——C. Alice, Bob and Chocolate(想法题)
- 多表查询
- liferay6.2 theme开发教程-第一节liferay theme主题开发系列教程第一讲-什么是theme
- QT多线程中的互斥与同步
- HDU 2671 Can't be easier
- BZOJ 1208: [HNOI2004]宠物收养所
- JavaScript 面向对象之构造函数+成员函数详解
- EditText中 InputType
- [Django入门知识浅介]Django框架里的MVC思想
- textview的drawablle属性
- 代码整洁之道学习(一)
- SPFA算法模板
- isfinite() isinf() isnan() isnormal()
- 软考系列——排序算法盘点
- Java总结篇系列:Java多线程(二)