摘要: function F() { Object.prototype.a = function () { console.log("a()"); }; Function.prototype.b = function () { console.log("b()"); }; } var f = new F() 阅读全文
posted @ 2022-01-15 17:51 haveProgress 阅读(245) 评论(0) 推荐(0) 编辑
摘要: 1: 对象字面量的方式 let o = {} 2: 通过Object.create() let o = Object.create({}) 3: 通过new 构造函数的方式 let o = new Object() function Person(name) { this.name = name } 阅读全文
posted @ 2022-01-15 17:51 haveProgress 阅读(1118) 评论(0) 推荐(1) 编辑
摘要: 什么是 构造函数constructor 函数名首字母必须大写 内部使用this对象,来指向将要生成的对象实例 使用new操作符来调用构造函数,并返回对象实例 构造函数用来干什么 所谓构造函数,就是提供了一个生成对象的模板并描述对象的基本结构的函数。一个构造函数,可以生成多个对象,每个对象都有相同的结 阅读全文
posted @ 2022-01-15 17:49 haveProgress 阅读(2380) 评论(0) 推荐(0) 编辑