上一页 1 ··· 3 4 5 6 7 8 9 10 下一页

2020年1月21日

摘要: //generator是可以用来控制迭代器的函数,可以暂停,也可以任何时候恢复function * loop () { for(let i = 0; i < 5; i++) { yield console.log(i) } } const l = loop() l.next() l.next() f 阅读全文
posted @ 2020-01-21 22:26 bobo2404 阅读(156) 评论(0) 推荐(0) 编辑
 
摘要: //场景一:可以修改对象的值let o = { name: 'xiaoming', price: 190 } let d = new Proxy(o,{ get (target,key){ if(key 'price'){ return target[key] + 20 }else{ return 阅读全文
posted @ 2020-01-21 16:36 bobo2404 阅读(468) 评论(0) 推荐(0) 编辑

2020年1月18日

摘要: let options = { title: 'menu', width: 100, height: 200 } //如果简写,变量名必须和属性名一致 let {title,width,height} = options console.log(title,width,height) let {ti 阅读全文
posted @ 2020-01-18 23:38 bobo2404 阅读(410) 评论(0) 推荐(0) 编辑
 
摘要: //数组解构 let arr = [1,2,3,4,5,6,7] let [one,two] = arr let [one, , ,four] = arr console.log(one,two,four) let arr = 'abcd' let [first, ,third] = arr con 阅读全文
posted @ 2020-01-18 23:07 bobo2404 阅读(101) 评论(0) 推荐(0) 编辑
 
摘要: //包含变量或表达式 const a = 10 const b = 20 const c = 'html' const str = `my age is ${a + b} i love ${c}` //包含逻辑运算的用法 function Price (strings,type){ let s1 = 阅读全文
posted @ 2020-01-18 21:10 bobo2404 阅读(848) 评论(0) 推荐(0) 编辑
 
摘要: const s = 'aaa_aa_a' const r1 = /a+/g const r2 = /a+/y console.log(r1.exec(s)) //aaa console.log(r2.exec(s)) //aaa console.log(r1.exec(s)) //aa consol 阅读全文
posted @ 2020-01-18 16:40 bobo2404 阅读(157) 评论(0) 推荐(0) 编辑
 
摘要: const target = { a: { b: { c: { d: 1 } }, e: 5, f: 6, h: 10 } } const source = { a: { b: { c: { d: 1 } }, e: 2, f: 3 } } Object.assign(target, source) 阅读全文
posted @ 2020-01-18 16:25 bobo2404 阅读(108) 评论(0) 推荐(0) 编辑

2020年1月17日

摘要: //map实例化,存入的数据格式是二维数组 let map = new Map() //添加 map.set(1,2) map.set(3,'value-3') //删除,通过key删除 map.delete(1) //清空 map.clear() //获取长度 map.size //判断是否存在对 阅读全文
posted @ 2020-01-17 23:46 bobo2404 阅读(195) 评论(0) 推荐(0) 编辑
 
摘要: set:无序的不重复的value的集合体 //实例化容器 let s = new Set()//方法一 let s = new Set([1,2,3,4])//方法二,里面存储可循环的数据,不一定是数组,对象,只要是可循环的都可以 //添加数据 //s.add('hello') //s.add('g 阅读全文
posted @ 2020-01-17 22:57 bobo2404 阅读(153) 评论(0) 推荐(0) 编辑
 
摘要: function sum (x = 1, y = 2, z = 3) { return x + y + z } let data = [4,5,9] console.log(sum(data[0],data[1],data[2])) console.log(sum.apply(this,data)) 阅读全文
posted @ 2020-01-17 19:08 bobo2404 阅读(169) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 下一页