摘要: 参数的默认值 与解构赋值结合 length属性 作用域 函数的name属性 ES5设置函数参数默认值: function foo(x, y) { y = y || 'world'; console.log(x, y); } foo('hello', 'girl'); foo('hello', 0); 阅读全文
posted @ 2021-05-28 18:04 火星_PGY 阅读(54) 评论(0) 推荐(0)
摘要: 类数组 / 伪数组 Array.from() Array.of() copyWithin() fill() includes() 类数组、伪数组例子: let divs = document.getElementsByTagName('div'); console.log(divs); // HTM 阅读全文
posted @ 2021-05-28 11:54 火星_PGY 阅读(52) 评论(0) 推荐(0)
摘要: 解构赋值:按照一定模式,从数组和对象中提取值,对变量进行赋值。 数组解构 对象解构 字符串解构 应用场景 曾经的赋值噩梦,非解构赋值数组: let arr = [1, 2, 3]; let a = arr[0]; let b = arr[1]; let c = arr[2]; console.log 阅读全文
posted @ 2021-05-28 11:38 火星_PGY 阅读(91) 评论(0) 推荐(0)
摘要: ES5中数组遍历方式: for循环 forEach():没有返回值,只是针对每个元素调用func map():返回新的Array,每个元素为调用func的结果 filter():返回符合func条件的元素数组 some():返回boolean,判断是否有元素、是否符合func条件 every():返 阅读全文
posted @ 2021-05-28 11:35 火星_PGY 阅读(107) 评论(0) 推荐(0)
摘要: 新声明方式:const 1、不属于顶层对象 window 2、不允许重复声明 3、不存在变量提升 4、暂时性死区 5、块级作用域 以上特性跟let声明一样,特性可看 let 的学习笔记:链接跳转 ES5里面定义常量: Object.defineProperty(window, "PI", { val 阅读全文
posted @ 2021-05-28 11:04 火星_PGY 阅读(57) 评论(0) 推荐(0)
摘要: 新声明方式:let 1、不属于顶层对象 window 2、不允许重复声明 3、不存在变量提升 4、暂时性死区 5、块级作用域 原来var声明: var a = 5; console.log(a); // 5 console.log(window.a); // 5 delete a console.l 阅读全文
posted @ 2021-05-28 10:56 火星_PGY 阅读(80) 评论(0) 推荐(0)
摘要: 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)