摘要:
我们在创建实例对象是,若忘了new const Book1 = function (title, time, type) { this.title = title this.time = time this.type = type } const book1 = Book1("JavaScript" 阅读全文
posted @ 2021-11-26 22:19
邢韬
阅读(68)
评论(0)
推荐(1)
摘要:
闭包的主要作用就是构建一个单独的作用域,里面的一些变量不会污染全局,又可以满足一些必要操作 比如bookNum,写在外部会污染全局,写在_book里函数中, 静态使用一次又会被销毁, 实例又无法从外部访问 const Book = (function () { // 私有变量 let bookNum 阅读全文
posted @ 2021-11-26 22:13
邢韬
阅读(41)
评论(0)
推荐(0)
摘要:
为了方便使用,防止污染全局变量,可以把一系列功能封装在一个类中使用 const CheckObj1 = function(){ this.checkName = function(){ console.log("checkName") } this.checkEmail = function(){ 阅读全文
posted @ 2021-11-26 22:09
邢韬
阅读(48)
评论(0)
推荐(0)

浙公网安备 33010602011771号