![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
js设计模式
js设计模式
plan_ b
这个作者很懒,什么都没留下…
展开
-
js-工厂模式
简单工厂模式 function createPerson(name) { var o = {} o.name = name o.getName = function() { console.log(this.name) } return o } var person1 = createPerson('zhang san') person1.getName() //zhang san console.log(person1原创 2021-07-26 22:52:39 · 74 阅读 · 0 评论 -
js中的new和面向对象
new的过程中发生了什么 function CreateCat(name) { this.name = name } var catA = new CreateCat('xiaoA') console.log(catA.name) /** * new的操作: * 1.创建了一个空对象 * 2.将构造函数的prototype属性赋值给新对象的__proto__属性 * 3.将构造函数的this指向新对象 * 4.执行构造函数的代码 * 5.将新对原创 2021-07-26 16:16:20 · 111 阅读 · 0 评论