随笔分类 - es6
摘要:// ES5中的类与继承// function People(name, age) { // 构造函数// // console.log(this) // this 指向当前new出来的实例化对象// // this.name this.age 是实例属性 实例属性是定义在构造函数里的// this
阅读全文
摘要:// proxy [ˈprɑːksi] 代理 // // es5代理方式 // let obj = {} // let newVal = '' // Object.defineProperty(obj, 'name', { // 第一个变量名称当前对象 第二个为当前对象的属性值 // get() {
阅读全文
摘要:// 正则表达式的拓展 y u修饰符 // i 忽略大小写 // m 匹配多行 // g 全局匹配 每次匹配剩余的 // y 修饰符 粘连修饰符 剩余的第一个开始匹配 // const str = 'aaa_aa_a' // const reg1 = /a+/g // +表示1次或多次 // //
阅读全文
摘要:// 新的数据解构Map key 值可以是不同类型的值 // let m = new Map()// let obj = {// name: 'hky'// } // m.set(obj, 'es') // 第一个值为key 值 第二个为value值// // console.log(m.get(o
阅读全文
摘要:// 一种新的数据解构 set// 成员值是唯一的// let s = new Set([1, 2, 3]) // // s.add('imooc').add('set') // 增加 链式操作// // s.delete(2) // 删除// // // s.clear() // 清空所有数据//
阅读全文
摘要:// 深拷贝与浅拷贝 // let target = {// a: {// b: {// c: 1,// f: 2// },// e: 3,// g: 11// }// }// let source = {// a: {// b: {// c: 1,// f: 2// },// e:5// }//
阅读全文
摘要://对象的拓展// let name = 'hky'// let age = 24// let obj = {// name: name,// age: age// }// console.log(obj)// 属性简介表达法// let name = 'hky'// let age = 24//
阅读全文
摘要:// 拓展运算符 把数组或者类数组展开成用逗号隔开的值 // function foo([a, b, c]) { // console.log(a, b, c); // } // let arr = [1, 2, 3] // foo(arr) // 结构赋值 左边=右边 // function fo
阅读全文
摘要://函数的参数 // function foo(x, y) {// y = y || 'world'// console.log(x, y)// }// // foo('hello', 'imooc')// foo('hello', 0) 有缺陷 不能输出 hello 0 // function f
阅读全文
摘要://数组的拓展 DOM document object model 文档对象模型 // let div = document.getElementsByTagName('div') // HTMLCollection // console.log(div) // let div2 = documen
阅读全文
摘要:let arr = [1, 2, 3, 2, 4] // ES5多种数组的遍历方式// for (let i = 0; i < arr.length; i++) {// // if (arr[i] == 2) {// // break// // }// if (arr[i] == 2) {// co
阅读全文
摘要:// 1 当数组作为参数的时候 // for 循环 数组内的数字相加 // sun += arr[i] // const sum = arr => { // 箭头函数一个参数可以去掉括号 (arr) // let result = 0 // for (let i = 0; i < arr.lengt
阅读全文
摘要:// 数组的解构赋值// let [a, b, [c, d]] = [1, 22, [323, 123123]]// console.log(a, b, c, d) // let [a, b, [c]] = [1, 22, [323, 123123]]// console.log(a, b, c)
阅读全文