//普通对象
//函数对象(有原型 prototy 的属性)
//原型的应用 继承
function Amial(){
this.type = '小于'
}
function cat(name){
this.name = name
}
cat.prototype = new Amial()
var cat1 = new cat('小张')
console.log(cat1.name,cat1.type) //构造器 继承 缺点:把父元素的属性都复制了
function Amial(){
this.type = '动物'
}
function amm(name){
Amial.apply(this) //调用Amial构造器 Amial == amm
//Amial.call(this,x,y,z) Amial.apply(this,[x,y,z])
this.name = name
}
var a = new amm('张三')
console.log(a.type) //组合继承(原型+构造器) 缺点:调用两次父类构造器 function Preson(name){
this.arr = ['js','php']
this.name = name
}
Preson.prototype.showname = function(){
console.log(this.name)
}
function teacher(name,gread){
Preson.call(this,name)
this.gread = gread
}
teacher.prototype = new Preson() // 最关键的一句
var a = new teacher('xiaoming', 23)
console.log(a.arr,a.name,a.gread)
a.showname() //原型+构造+寄生
function father(name){
this.arr = ['aa','bb']
this.name = name
}
father.prototype.showname = function(){
console.log(this.name)
}
function son(name,course){
father.call(this,name)
this.course = course
}
function extend(subobj,superobj){
var proobj = Object.create(superobj.prototype)
subobj.prototype = proobj
}
extend(son, father)
var a = new son('xiaoming', 23)
console.log(a.arr,a.name,a.course)
a.showname()

最新文章

  1. JMM(java内存模型)
  2. 获取URL最后一个 ‘/’ 之后的字符
  3. delphi软件启动的顺序解密。
  4. android 中如何分析内存泄漏
  5. jquery input选择弹框
  6. jquery 导航固定的一个实例
  7. PySpark关于HDFS文件(目录)输入、数据格式的探讨
  8. web前端面试试题总结---javascript篇
  9. ubuntu中KDE与GNOME安装切换
  10. 字符串处理,NSNumber转换
  11. python读取文本文件数据
  12. Visual Studio 2017的一些使用记录
  13. MySQL连接java
  14. FCC JS基础算法题(4):Title Case a Sentence(句中单词首字母大写)
  15. 20155330 《网络攻防》 Exp3 免杀原理与实践
  16. ssh-copy-id 复制公钥到远程server
  17. java数字格式化
  18. 『Collections』Counter计数
  19. 【转】每天一个linux命令(10):cat 命令
  20. 基于obs+nginx-rtmp-module搭建自己直播的系统

热门文章

  1. 关于 map 的迭代器
  2. JupyterNotebook开发介绍
  3. python学习:窗口程序
  4. 用户警告:“importlib-metadata”版本与“setuptools”不兼容。升级importlib-metadata
  5. ubuntu添加新硬盘进行分区,并挂载到/home
  6. KEIL5中C/C++优化等级问题
  7. C++实现双向链表的相关操作代码
  8. spring cloud 配置文件加密解密
  9. vscode - plug - scss转css
  10. Java基础——(综合练习)普通加密