1.创建对象有几种方法
var o1 = {name:'o1' }
var o11 = new Object ({name:'011' })
var M = new Function (){this .name=m}
var m =new M()
var P={name:'o3' }
var o3 = Object .create(P)
2.原型链
3. instanceof 原理
实例对象的proto 和构造函数的protoType 是否是同一个引用
4.类的声明
function Animal (name) {
this .name = name;
}
class Animal2 {
constructor () {
this .name = 'a'
}
}
new Animal('ss' );
new Animal2();
5. 类的继承方式
function Parent1 () {
this .name = 'parent1'
}
function Child1 () {
Parent1.call(this )
this .type = 'child1'
}
console.log(new Child1())
function Parent2 () {
this .name = 'parent1'
}
function Child2 () {
this .type = 'child1'
}
Child2.prototype = new Parent2();
function Parent3 () {
this .name = 'parent1'
}
function Child3 () {
Parent3.call(this )
this .type = 'child1'
}
Child3.prototype=new Parent3()
function Parent4 () {
this .name = 'parent1'
}
function Child4 () {
Parent4.call(this )
this .type = 'child1'
}
Child4.prototype=Parent4.prototype
function Parent5 () {
this .name = 'parent1'
}
function Child5 () {
Parent5.call(this )
this .type = 'child1'
}
Child5.prototype=Object .create(Parent5.prototype)
Child5.prototype.constructor=Child5