function A(name,age) { var o = new Object() o.name = name o.age = age o.sayName = function () { alert(this.name) } return o}var A1 = new A('qwe',18)console.log(A1 instanceof A); //不是A的实例吗?console.log(A1 instanceof Object);function B(name,age) { this.name = name this.age = age}var B1 = new B('asd', 12)console.log(B1 instanceof B);console.log(B1 instanceof Object);请问从哪体现呢?
3 回答
侃侃无极
TA贡献2051条经验 获得超10个赞
1)创建对象的过程中并没有体现出工厂模式。
2)可以了解下js通过构造函数创建对象的过程,应该就能解释 console.log(A1 instanceof A); //不是A的实例吗?
添加回答
举报
0/150
提交
取消