摘要: class jQuery { constructor(selector) { const result = document.querySelectorAll(selector) console.log(result) const length = result.length for (let i 阅读全文
posted @ 2020-08-09 10:59 火星_PGY 阅读(174) 评论(0) 推荐(0)
摘要: Class的使用: // 父类 class People { constructor(name) { this.name = name } eat() { console.log(`${this.name} eat`) } } // 子类 class Student extends People { 阅读全文
posted @ 2020-08-09 10:57 火星_PGY 阅读(628) 评论(0) 推荐(0)
摘要: const obj = { a: 100, b: { b1: [1, 2, 3], b2: 'string' }, c: ['a', 'b', 'c'] } /* * 没做深拷贝的效果 const obj2 = obj obj2.a = 200 obj2.b.b2 = 'abc123' obj2.c 阅读全文
posted @ 2020-08-09 10:50 火星_PGY 阅读(307) 评论(0) 推荐(0)
摘要: var arr = [1,2,3,4,5] console.log(arr.slice(1,4)) console.log(arr) Function.prototype.bind1 = function(){ // arguments是个列表不是数组,将参数拆解为数组 const args = A 阅读全文
posted @ 2020-08-09 10:42 火星_PGY 阅读(276) 评论(0) 推荐(0)
摘要: 什么是闭包,闭包的表现形式: // 作用域应用的特殊情况,有两种表现: // 函数作为参数被传递 // 函数作为返回值被返回 // 函数作为返回值 function create() { let a = 100 return function () { console.log(a) } } let 阅读全文
posted @ 2020-08-09 10:41 火星_PGY 阅读(369) 评论(0) 推荐(0)